James B.

asked • 10/18/21

Please code in c++. I need help on this one.

 Write a program that prompts users to enter:

 

o A character to use (any character besides *)

o The width of the display

o The height of the display

 

to produce an E shape. The middle horizontal line must print at line (height+1)/2. Validate user input to only be positive values and height must be at least 5 and width 2. Any invalid input must loop until a valid value is entered.

 

This is an example for width of 10 and height of 9

 

**********

*     

*     

*     

**********     

*     

*     

*     

**********

 

You must use separate functions to display the vertical and the horizontal lines.  


1 Expert Answer

By:

Quintin B.

Would you recommend a for loop or a while loop for you main function? I'm stuck at where to start.
Report

03/08/22

Greg H.

tutor
I would call print_horizontal_line(), then create a loop to call print_vertical_line(( as many times as necessary, etc. Either a for or whole loop would work, but a for loop would be a little bit easier to write.
Report

03/08/22

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.