7A
Write the application, TheSentinel
to read a set of integers. Stop reading input when a non-integer is read. Use this exact prompt: System.out.print("Enter an integer or Q to quit: ");
Note: you will actually quit on any non-integer.
Do the following things:
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"
For the draft, read the values. Calculate and print the sum of the even integers. If there were no inputs, just print "no input"
7B
Write a BeninFlag
class that draws the Benin flag. You can start with one of the flag classes from the Horstmann videos Lesson 5.1 and modify it.
The Benin flag should look like the one below. The flag has two equal horizontal bands of yellow (top) and red (bottom) with a vertical green band on the hoist side. The green is exactly 1/3 of the width. Draw the rows and then the columns. Use the predefined colors in the Color class.
You will need to import the Horstmann graphics package.
The green symbolizes hope and revival, yellow wealth, and red courage
For the draft, draw the yellow horizontal band. The rest of the picture will be white.
Here is the completed flag
7C
Write an application CirclesViewer
to fills 6 rows with red circles like the image below. The first row has one circle; the second row has two circles and so on. The diameter of each circle is 50. The coordinate of the upper left-hand corner of the circle in the top row is (0, 10).
Fill the first row, then the second and so on. Only use fill. Do not use draw.
You must use nested loop. There should only be one fill statement. No credit for filling many individual circles
For the draft, fill the first column