Question: C++ CS121 General Description: You are to write a program that asks the user for a choice of pattern, and then a choice of size.

C++

CS121

General Description: You are to write a program that asks the user for a choice of pattern, and then a choice of size. It will produce, on the screen, a square with the particular pattern of the given size (see examples on separate sheet.)

Details:

1. The program will keep repeating until the user chooses to quit

2. There are 4 patterns to choose from: (again, see examples)

i. a square with a left to right diagonal in which the diagonal is the size of the square

ii. a square with a right to left diagonal in which the diagonal is the size of the square

iii. a square that fills from left to right, using the size of the square as the fill character

iv. a square that fills from right to left, using the size of the square as the fill character

If the user tries to make an invalid choice, the program should keep asking for a valid choice

3. There are 9 sizes to choose from: 1 9

If the user enters an invalid size, the program should keep asking until a valid size is entered

4. You MUST use a switch statement in your code for the pattern choice.

5. You MUST use a do-while loop to repeat the program for the user.

6. You MAY use functions in your code if you know how, but they are not required.

7. You must have internal documentation:

8. I do NOT want to see 36 different patterns hard-coded into the program!!

You should have one block of code for each pattern which produces the correct pattern and size.

SAMPLE OUTPUT

C++ CS121 General Description: You are to write a program that asks

SAMPLE OUTPUT WITH INVALID INPUT

the user for a choice of pattern, and then a choice of

Screen 3 of 5 CA Your options are: 1: A square with a left to right diagonal 2: a square with a right to left diagonal 3: a square that fills left to right 4: a square that fills right to left 5: exit hich choice? 2 Please pick a size, from 1 through 9: 6 ####6# ###6## ##6### our options are: 2: a square with a right to left diagonal 4: a square that fills right to left 5: exit which choice? 3 Please pick a size, from 1 through 9: 4 44## 444 Your options are: 1: A square with a left to right diagona 2: a square with a right to left diagonal 3: a square that fi11s left to right 4: a square that fills right to left which choice? 5 ou chose to exit, goodbye! Press any key to continue

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!