Java: Print an American flag on the screen
American Flag Display
Write a Java program to print an American flag on the screen.
Pictorial Presentation:
Sample Solution:
Java Code:
Sample Output:
* * * * * * ================================== * * * * * ================================== * * * * * * ================================== * * * * * ================================== * * * * * * ================================== * * * * * ================================== * * * * * * ================================== * * * * * ================================== * * * * * * ================================== ============================================== ============================================== ============================================== ============================================== ============================================== ==============================================
Flowchart:
Sample Solution:
Java Code:
Output:
* * * * * * ================================== * * * * * ================================== * * * * * * ================================== * * * * * ================================== * * * * * * ================================== * * * * * ================================== * * * * * * ================================== * * * * * ================================== * * * * * * ================================== ============================================== ============================================== ============================================== ============================================== ============================================== ==============================================
Flowchart:
For more Practice: Solve these Related Problems:
- Modify the program to display a different country’s flag using characters.
- Write a program that prints the American flag with stars aligned dynamically.
- Modify the program to print the flag using only '*' and '-' characters.
- Create a function that prints a scaled version of the flag based on user input.
Java Code Editor:
Previous: Write a Java program to print the area and perimeter of a rectangle.
Next: Write a Java program to swap two variables.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.