Project #6 - Flag
Make a program that displays the American flag (without using images)
REQUIREMENTS
Your program must use loops and modulus to display the American flag
It must have 13 stripes that alternate between red and white
It must have 50 stars divided into staggered 9 rows of 5 and 6.
Resources
Shiffman - Loops (2:50 to 3:04)
STEP BY STEP
Part A - Stripes
Create the setup method
Set the window size to 1300 x 650
Set the background to white
Turn off stoke
Use a for loop to draw 7 red rectangles
Hint: Use the loop variable and multiplication for the y coordinate of each rectangle.
Hint #2: Make the rectangles be positioned 100 apart, but only 50 tall.
Your program should show horizontal red and white stripes.
Part B - One Row of Stars
Draw the flag’s deep blue field in the upper left corner
Suggested size: 500 x 350
Write a method called void rowSix(int yPos) that draws a row of six stars at a specified yPosition
You’ll need to experiment to find out how to space the stars horizontally
Call rowSix() to draw a single row of stars
Suggested value: Call rowSix with 35 as a parameter
A flag with a single row of stars
Part C - Grid of Stars
Write a method called void rowFive(int yPos) that draws a row of five stars at a specified yPosition
Call rowFive to draw a single row of stars
Suggested value: Call rowSix with 70 as a parameter
Call the methods rowSix() and rowFive() repeatedly at different y values until you’ve drawn all the stars
Hint: You’ll call rowSix 5 times and rowFive 4 times. Keep spacing them 35 apart.
Part D - Cleaning Up The Code
The above code works, but it’s kind of messy. Let’s clean it up by using another loop and modulus.
Write a for loop that executes 9 times - one for each row of stars.
For this part, you’ll want to start at i = 1, instead of 0.
If your loop variable(i) is even
Call rowFive(i * 35)
Else
Call rowSix(i * 35)
Hint: You can check if a number is even or odd using modulus.
Your output will still look the same, but the code should be much shorter.