Question: Can anyone help me with this programming assignment? It has to be in the Java language Overview In this assignment you will write a program

Can anyone help me with this programming assignment? It has to bein the Java language Overview In this assignment you will write aprogram that will use nested loops to print either a pyramid ora diamond of s of a given size. It will ask theuser for the height, and then if they want a diamond patterninstead. If the user want to do the diamond, the program printsout an upside down pyramid under the first to make the diamondshape. For example t**k* Requirements Your program must do the following inorder to receive full credit on this assignment. 1. Ask the userCan anyone help me with this programming assignment? It has to be in the Java language

Overview In this assignment you will write a program that will use nested loops to print either a pyramid or a diamond of s of a given size. It will ask the user for the height, and then if they want a diamond pattern instead. If the user want to do the diamond, the program prints out an upside down pyramid under the first to make the diamond shape. For example t**k* Requirements Your program must do the following in order to receive full credit on this assignment. 1. Ask the user to provide the height of the pyramid. This must be at least 1 and no greater than 25 2. 3. a. Store the height that the user has provided. Verify that the user has typed in a valid height. a. If they have not, accept new values from the user until they enter a valid height 4. Ask the user if they would like a diamond instead of a pyramid. The user must type "Yes" or "No". b. a. If the user types neither of these, ask again until they provide appropriate input. 5. Set a boolean to store whether they want a pyramid or a diamond. Print out a message to show the user which you will be printing. a. Start a main loop to print out a pyramid. This will need to run once for every line of the pyramid. Note that you will need to do this whether they asked for a diamond or not (see below 6. a. Add the appropriate number of preceding spaces for the current line i. For example, on the first line this will be height 1 b. Add the appropriate number of *'s for that line. i. On the first line, this would be 1 which is height 1 spaces away from the left edge, which will be the start of the middle column. ii. Each additional line will need one more in front of the middle column, and one more after the column. 1. So, the second line would have 3 *'s. i The last line will have (height * 2)-1) *'s on it. 7. Now that the pyramid has been printed, print the bottom half if the user asked for you to print a diamond. b. This time you will need one fewer *'s per line before and after the column until you end with just 1 * on the last line. i. The opposite goes for preceding spaces, in that you need more per line. ii. This will all be almost the same logic, just in reverse. i Make sure you don't print the last line of the pyramid a second time when making a diamond. Example Inputs Below are five example runs of the program with the inputs and outputs. Remember, the graders will be testing your program against these as well as their own, so make sure you test these and come up with your own before submitting your program. #1 Please type in the height of the tree It must be at least 1 high and no more than 25 Would you like a diamond instead of a pyramid? Type Yes or No. No Printing a pyramid #2 Please type in the height of the tree. It must be at least 1 high and no more than 25 Would you like a diamond instead of a pyramid? Type Yes or No. Yes #2 Please type in the height of the tree It must be at least 1 high and no more than 25 4 Would you like a diamond instead of a pyramid? Type Yes or No Yes Making a diamond instead #3 Please type in the height of the tree It must be at least 1 high and no more than 25. 42 Invalid height. Please try again Invalid height. Please try again 26 Invalid height. Please try again 8 Would you like a diamond instead of a pyramid? Type Yes or No. No Printing a pyramid. Type Yes or No. No Printing a pyramid #4 Please type in the height of the tree It must be at least 1 high and no more than 25. 2 Would you like a diamond instead of a pyramid? Type Yes or No. cheese Invalid input. Please try again yes Making a diamond instead #5 #5 Please type in the height of the tree It must be at least 1 high and no more than 25. Would you like a diamond instead of a pyramid? Type Yes or No. Yes Making a diamond instead

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!