Question: In Java Language. This is an intro class, so we haven't learned all that much, so if you could, try not to use too advanced

In Java Language. This is an intro class, so we haven't learned all that much, so if you could, try not to use too advanced formatting as we likely have not learned them. Please try and run all the example in your program to make sure you get the outputs expected. Thank you

In Java Language. This is an intro class, so we haven't learnedall that much, so if you could, try not to use tooadvanced formatting as we likely have not learned them. Please try andrun all the example in your program to make sure you getthe outputs expected. Thank you CSE 110: Principles of Programming Languages Assignment4 Overview In this assignment you will write a program that willuse nested loops to print cither a pyramid or a diamond of's

CSE 110: Principles of Programming Languages Assignment 4 Overview In this assignment you will write a program that will use nested loops to print cither a pyramid or a diamond of's of a given size. It will ask the user for the height, and then if thcy 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 tx xx**x*x k*xk** oR 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 a. This must be at least 1 and no greater than 25 2. Store the height that the user has provided. 3. Verity 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. a. The user must type "Yes" or "No" b. If the user types neither of these, ask again until they provide appropriate input . Set a boolean to store whether they want a pyramid or a diamond. 5. Set a boolean to store whether they want a pyramid or a diamond. a. Print out a message to show the user which you will be printing. 6. 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). a. Add the appropriate number of preceding spaces for the current line i. For example, on the first line this will be height 1 i. On the first line, this would be which is height 1 spaces away from ii. Each additional line will need one more * in front of the middle column, b. Add the appropriate number of's for that line. the left edge, which will be the start of the middle column. and one more after the column 1 So, the second line would have 3 's The last line will have ((height 2)-1 ) *'s on it. ii. 7. Now that the pyramid has been printed, print the bottom half if the user asked for you to print a diamond. a. Again, you need an outer loop b. This time you will need one fewer *s per line before and after the column until you end with just I *on the last line. i. The opposite goes for preceding spaces, in that you need more per line. ii 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. 4 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. 4 Would you like a diamond instead of a pyramid? Type Yes or No. Yes Making a diamond instead. *k #3 #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. -9 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. x**xx kx*k***k**k x #4 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. cheese Invalid input. Please try again. yes Making a diamond instead #5 Please type in the height of the tree. It must be at least 1 high and no more than 25. Would you TiKe a diamond instead of a pyramid? Type Yes or No. cheese Invalid input. Please try again. yes Making a diamond instead. #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 Submission Please submit your Assignment4.java file to the Assignment 4 link on Blackboard under the Assignments tab. You may submit as many times as you want prior to the due date, in case you later find and fix an error, but only the last one is graded

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!