7A
Updated Oct 10
Write an application called TheSentinal
which asks the user to enter the elevation (either above or below sea level) in a particular region. The input stops when the user enters a non-double. Use this exact prompt before the while loop: System.out.print("Enter an elevation or Q to quit: "); Use this prompt in the while loop: System.out.print("Enter an integer or Q to quit: ");
Note: you will actually quit on any non-double
Also note: The second prompt ideally would be the same as the first, but Codecheck expects the word "Integer" so use it. See the exampl below to help you get started.
Do the following:
You will only read the inputs one time and do all the processing as you go. No arrays yet.
The outputs should be on separate lines and in the order given above. If there were no inputs, just print "no input" and nothing else
This is skeleton for whar you will do
import java.util.Scanner; /** * Get a set of elevations and print some info about them */ public class TheSentinel { public static void main(String[] args) { //declare the scanner //declare necessary variables System.out.print("Enter an elevation or Q to quit: "); while (...) { //code to get and process input System.out.print("Enter an integer or Q to quit: "); } //more code here } } }
For the draft, read the values. Calculate and print the number of locations below sea level. If there were no inputs, just print "no input"
7B
Write a application CircleViewer
that will draw 10 concentric circles. Concentric means with the same center. The drawing has the following specifications:
You must use a loop. No credit for drawing 10 individual circles
For the draft, just draw the first, innermost circle.
7B draft:
7B final: (link updated Oct 16. You must adjust your code and rerun it to get full credit.)
There was an error in Codecheck for hw7 final. The homework was updated today Oct 16 with a new corrected link.
If you fiddled with the numbers so your code passed the incorrect Codecheck, your solution is incorrect.. You need to resubmit the corrected code to the corrected link and upload that report.
Do not turn in incorrect code even if it passes the old Codecheck.
7C
Write a class ChadFlag
that represents the flag of Chad. You can start with one of the flag classes from the Horstmann videos Lesson 5.1 and modify it.
The constructor takes the width and height of the flag and also draws the flag. You must use is a helper method, getColor(x, y) which returns the color of the specified pixel
The Chadian flag should look like the one below. The flag has three equal vertical band: blue ( on the hoist side), gold (yellow) in the center and then red. Each color is exactly 1/3 of the width. Draw the rows and then the columns.
The colors:
You will need to import the Horstmann graphics package.
The blue symbolizes the sky, the gold represents the sun, and the red stands for progress, unity, and sacrifice
For the draft, draw the blue vertical band. Make the rest of the flag black - just for the draft
Here is an image of a Chad flag from The World Factbook. Yours will be similar but the color will be a little different.