Question
Add for loops or while loop on // Place your code starting here to make the output look the same as all the pictures below.
Add for loops or while loop on // Place your code starting here to make the output look the same as all the pictures below.
In order to cause the backslash character itself to show up in your output, you must put two backslashes in a row inside double quotes, such as: cout
we do not expect you to use functions (though you may if you want to).
Suggested steps
starter code.cpp
#include // for cin and cout #include // for setw. The number in setw(...) is the total of blank spaces including the printed item.
using namespace std; // so that we don't need to preface every cin and cout with std::
int main() { // Display the menu and get the user choice int menuOption = 0; cout "; cin >> menuOption;
// Handle menu option of 3 to exit if (menuOption == 3) { exit(0); } // Handle menu option of 1 to display custom ASCII graphics else if (menuOption == 1) { // My own graphic. You must create your own. cout
else if (menuOption == 2) { // Prompt for and get the number of dolls. int numberOfDolls = 0; cout "; cin >> numberOfDolls;
// Place your code starting here // ...
} //end if( menuOption == 2) // menu option to display dolls
cout
Output
Suggested Steps The steps described below will help you make progress. You may want to see if you can first do it on your own without these steps. Then if you get stuck you can come back and take a look 1. After prompting for how many dolls, use a loop to display a single forward slash on a single line for each section, with a line of three dashes after each one. Thus if the user chooses 3 dolls the output might look like: 2. Add a loop inside your existing loop so each doll has the appropriate number of lines, though each line is still just a forward slash. This should work for any input number, giving the right number of dolls, and the right number of lines per doll. 3. Add a loop or a setw(output width specifier to display the appropriate number of blanks before each forward slash. To do this you will need to figure out a formula On each line you know how many dolls there are and which line you are on. Using these two numbers figure out some formula that gives the appropriate width of blank spaces to be displayed before each. Your output should now look like: 3. Add a loop or a setw() output width specifier to display the appropriate number of blanks before each forward slash. To do this you will need to figure out a formula. On each line you know how many dolls there are and which line you are on. Using these two numbers figure out some formula that gives the appropriate width of blank spaces to be displayed before each 7. Your output should now look like: 3. Now that we have the top section of the doll, lets add an additional loop that will generate the dolls bottom section. Maybe also add the code to give the correct number of leading spaces before the lines as well. This should now look like: 4. Similarly continue with figuring out the number of blank spaces to be displayed before the ' for top section and for bottom section is displayed at the end of each line. At this point you've probably got the hang of it, breaking down the problem into smaller steps where each one may be challenging, but possible to do. Don't forget to check the programs grading criteria in the syllabus, and don't forget to submit the final version to Gradescope so we can give you program style points. Program 1: Matryoshka Dolls Choose from among the following options: 1. Display original graphic 2. Display Matryoshka Dolls 3. Exit the program Your choice => 2 Number of dolls -> 1 1- 1/ Exiting Running the program again, but this time with 2 dolls gives: Program 1: Matryoshka Dolls Choose from among the following options: 1. Display original graphic 2. Display Matryoshka Dolls 3. Exit the program Your choice -> 2 Number of dolls -> 2 7 - VZ ) /: Exiting And again, but this time with 3 dolls: Program 1: Matryoshka Dolls Choose from among the following options: 1. Display original graphic 2. Display Matryoshka Dolls 3. Exit the program Your choice -> 2 Number of dolls -> 3 Exiting And yet again, but this time with 4 dolls: Program 1: Matryoshka Dolls Choose from among the following options: 1. Display original graphic 2. Display Matryoshka Dolls 3. Exit the program Your choice -> 2 Number of dolls -> 4 1 - 1 / \/ ( ) Exiting () Exiting ... and so on for any number of dolls given as input. The other menu option displays your own custom ASCII image. My sample version gives the following: Program 1: Matryoshka Dolls Choose from among the following options: 1. Display original graphic 2. Display Matryoshka Dolls 3. Exit the program Your choice => 1 Happy New Year! Welcome to: 2022 Exiting
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started