Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program PrintTriangles.java prints out triangles and diamonds according to the user input. It first prints out a menu requesting the user to indicate which shape
Program PrintTriangles.java prints out triangles and diamonds according to the user input. It first prints out a menu requesting the user to indicate which shape the user wants. The user then inputs the size. Both the shape choice and the size have to be within the limit set by the program. If the user input is not correct, user is required to input again. The following demonstrates what the program does in details (Those in [] are comments to explain the output. You do not have to print them out in your program). The output samples are also available in electronic format.- Output 14 This program prints a shape with a certain size of your choice. You have to select the shape from one of the following: 0 -- right-angled triangle with the right angle in the lower left 1 -- right-angled triangle with the right angle in the upper left 2 -- right-angled triangle with the right angle in the lower right 3 -- a diamond After selecting the shape, you will be asked to input the size of the shape. For triangles, the size is the width and height of the triangle. This size must not be larger than 15. For diamonds, the size tells the number of * on the longest row. The size must be an odd number not larger than 15.4 Enter the choice of your shape:4 [user input 4 is not valid, ask again] Enter the choice of your shape:-1 [user input -1 is not valid, ask again] Enter the choice of your shape:0 [user input 0 is valid, ask size] Enter the size of your shape:16 [user input 16 is not valid, ask again] Enter the size of your shape:4 [user input 4 is valid, print shape] **e *** **** Output 24 This program prints a shape with a certain size of your choice. You have to select the shape from one of the following: 0 -- right-angled triangle with the right angle in the lower left 1 -- right-angled triangle with the right angle in the upper left 2 -- right-angled triangle with the right angle in the lower right 3 -- a diamond After selecting the shape, you will be asked to input the size of the shape. For triangles, the size is the width and height of the triangle. This size must not be larger than 15. For diamonds, the size tells the number of * on the longest row. The size must be an odd number not larger than 15.- Enter the choice of your shape:14 Enter the size of your shape:64 ******* ***** **** *** Output 3 This program prints a shape with a certain size of your choice. You have to select the shape from one of the following: 0 -- right-angled triangle with the right angle in the lower left 1 --right-angled triangle with the right angle in the upper left 2 -- right-angled triangle with the right angle in the lower right- 3 -- a diamond After selecting the shape, you will be asked to input the size of the shape. For triangles, the size is the width and height of the triangle. This size must not be larger than 15. For diamonds, the size tells the number of * on the longest row. The size must be an odd number not larger than 15. Enter the choice of your shape:24 Enter the size of your shape:8 ** *** **** ***** ****** ******* ******** Output 4 This program prints a shape with a certain size of your choice.- You have to select the shape from one of the following: 0 -- right-angled triangle with the right angle in the lower left- 1 -- right-angled triangle with the right angle in the upper left 2 -- right-angled triangle with the right angle in the lower right 3 -- a diamond After selecting the shape, you will be asked to input the size of the shape. For triangles, the size is the width and height of the triangle. This size must not be larger than 15. For diamonds, the size tells the number of * on the longest row. The size must be an odd number not larger than 15.- Enter the choice of your shape:34 Enter the size of your shape:6 Enter the size of your shape:9- [user input 6 is not valid, ask again] Enter the size of your shape.ge *** ***** ***** ******* ***** *** e We have developed the skeleton of PrintTriangle.java. The skeleton does not check user input and only prints out the shape of Choice 0. Develop the full version as described above
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