Question: (Java please, simple program) Write a program using a Scanner that asks the user for a number n between 1 and 9 (inclusive). The program

(Java please, simple program)

Write a program using a Scanner that asks the user for a number n between 1 and 9 (inclusive). The program prints a triangle with n rows. The first row contains only the square of 1, and it is right-justified. The second row contains the square of 2 followed by the square of 1, and is right justified. Subsequent rows include the squares of 3, 2, and 1, and then 4, 3, 2 and 1, and so forth until n rows are printed.

Assuming the user enters 4, the program prints the following triangle to the console

(Java please, simple program) Write a program using a Scanner that asks

Note: If you choose to use a switch statement in your program, you'll have to use break inside the body of the switch. Otherwise, break and continue are completely unnecessary, and are really go-to statements with implicit destinations. Don't use them.

1 16 9 4 1 Grading Elements Program asks the user for a number in the specified range Program displays the correct number of rows Program displays the correct number of columns Each column entry contains the appropriate square number Each row is right-justified, with 1 in the right-most column Row spacing is consistent with each column's entry directly below the preceding row

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!