Allan Didier

Star Patterns

Goals

Write a Java program that prints various patterns of stars.

Skills

  • For loops

Program Details

Write a program (or programs) that will output the following patterns to the console.

Pattern #1 (left aligned)

*
**
***
****
*****


Pattern #2 (right aligned)

       *
     **
    ***
  ****
*****


Pattern #3 (centered)

        *
      ***
    *****
  *******
*********


Pattern #4 (numbered and centered)

        1
      222
    33333
  4444444
555555555


Extra Credit:
Write your program such that the user enters the number of rows and your program prints the above patterns with the number of rows the user entered. The patterns above patterns all have 5 rows.

Resources

Edhesive Term 1

Lesson 24: For loops