Completion requirements
This chapter discusses how control structures such as loops and if statements can be combined together to implement program logic.
21. Printing a Row of Stars
Answer:
With a loop that counts 1 to numStars
and prints a *
for each iteration.
Printing a Row of Stars
// collect input data from user System.out.print( "How many Stars per Row? " ); numStars = scan.nextInt() ; int star = ; while ( star <= ) { System.out.print("*"); } System.out.println(); |
Question 21:
Need I ask? Fill in the blanks so that numStars
stars are printed.