Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
(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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started