Question: I need to write a C++ program that does the following: prints an hour glass shape using the character '&'. It will ask the user

I need to write a C++ program that does the following:

prints an hour glass shape using the character '&'. It will ask the user to input both the number of charcters in the top row and the number of rows from the top to the middle.

So if the user input 7 for the number of '&' in the top row and 3 for the number of rows from the top to the middle row it would output this:

&&&&&&&

&&&&&

&&&

&&&&&

&&&&&&&

(there should be spaces before rows 2-4 so that it is symmetrical and looks like an hour glass)

no row can have less than 2 "&'s and there should be code to check for this.

it should first prompt the user to input the number of &s in the top row and then the number of rows from the middle to the top (these should be separate prompts/inputs, and should each output an error code if the input is invalid, and then say "Enter the number of &s in the top row again"/"Enter the number of rows again" until a valid number is input).

Please check the program thoroughly to make sure it always gives an error code for an invalid input and always outputs the correct hour glass shape!! it would also be nice if you could include some comments identifying what each part of the program is doing.

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!