The purpose of this project is to provide

The purpose of this project is to provide you with practice using conditional statements, loops, and functions. Your task is to write a program that allows a user to display a simple graphic shape using text symbols. Five basic shapes are allowed: V-shape, Hat-shape, X-shape, Right-Arrow-shape, and the Left-Arrow-shape. The shapes are defined as follows:

Type Parameters Limitations Sample Input Sample

Output

V-shape Number of rows

(n)

0 < n < 30 V 4 * *

* *

* *

*

Hat-shape Number of rows

(n)

0 < n < 30 H 4 *

* *

* *

* *

X-shape Number of rows

(n)

0 < n < 30

and

n is odd

X 5 * *

* *

*

* *

* *

Rightarrowshape

Number of rows

(n)

0 < n < 30

and

n is odd

R 5 *

**

***

**

*

Left-arrowshape

Number of rows

(n)

0 < n < 30

and

n is odd

L 5 *

**

***

**

*

Your project should provide an interactive menu system that allows a user to select the type of object to display.

The following menu items must be provided: V, H, X, R, L, and Q. The meanings of these items are:

V – V shape

H – Hat shape

X – X shape

R – Right arrow shape

L – left arrow shape

Q — quit.

The letter indicates which shape to display and will always be followed by a space and an integer value

representing size of the shape. Valid input can be uppercase as well as lowercase characters. All other letters

entered as command inputs are considered invalid. Provide a mechanism to allow a user to recover from an error.

For example, if the user enters a Z, do not terminate the program. Inform the user that an error has occurred,

display an error message, and discard the erroneous information i.e. if an incorrect command is detected, make

sure to flush the input buffer using cin.ignore(80,’n’).

A valid shape command code will always be followed by an integer valued size. The value provided may not be

acceptable based on the limitations outlined in the table. If you detect an invalid size, display a meaningful error

message, reject the command, and allow the user to enter a new command.

Program Design:

To solve this program, you need to decompose the problem into manageable pieces. Fortunately, the program

naturally breaks into functional units based on the different shapes. Design your solution so that your main

program calls functions to complete the various tasks. For example there should be functions to display each

shape, and there should one or more functions to get a valid command code.

Tags: No tags