Question: JAVA (Java please, simple program) Write a program using a Scanner that asks the user for a number n between 1 and 9 (inclusive). The
(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 16 9 9 4 4 1 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 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
