Question: What loops can I add to this code and how? Requirements and pre-written code below. C++ #include using namespace std; char enterOption() { char opt;

What loops can I add to this code and how? Requirements and pre-written code below. C++

What loops can I add to this code and how? Requirements and

#include

using namespace std;

char enterOption()

{

char opt;

cin >> opt;

return opt;

}

int main()

{

char option;

cout

cout

cout

option=enterOption();

if (option=='a')

{

cout

cout

cout

cout

option=enterOption();

if (option == 'a')

{

cout

cout

cout

option=enterOption();

if (option == 'a')

{

cout

}

else

{

cout

}

}

else

{

cout

}

}

else

{

cout

cout

cout

option=enterOption();

if(option == 'a')

{

cout

}

else

{

cout

cout

cout

option=enterOption();

if(option == 'a')

{

cout

}

else

{

cout

}

}

}

return 0;

}

Modify your Multipath Adventure from the previous lab to include loops. The criteria by which you will be graded are listed under "Special Requirements Graded by TAs". We suggest that you fulfill the requirements by doing the following (however, these are only suggestions): Use a while loop to enable the player to play your game multiple times Create an input function that utilizes a loop to prompt for and validate user input Takes a prompt (string) as the argument Returns the valid input (string) For the requirement to use at least 1 for loop: Consider using for loop(s) to draw box or stars around prompt in your input function (see above) For the requirement to use at least 1 instance of rand(): . Consider including a randomized process in your game, such as rolling a die, and using rand() to simulate the process Consider including a point where the game randomly selects between multiple possible descriptions. For example, you could have the game randomly decide whether to describe the weather as 'sunny" or "rainy". (If your code already fulfilled these, then you are done!) If you need to, you can adjust the decision tree as you are programming. Resubmit the final decision tree with the lab submission quiz. Note that you are allowed to use concepts we have not covered in class if you would like to. This might also help you in preparing for future labs. As part of grading your lab, the TAs will randomly pick 2 paths through your decision tree to check your work. They will reference your submitted decision tree to choose the paths and make sure that when they run your code it takes them through the path as specified in your decision tree To make your game easier to play and thus make it easier for the TAs to grade) you should provide prompts before each input that make clear what inputs are valid. A Note On Represent Loops in your Decision Tree If you choose to represent a loop on your decision tree with an arrow, make sure that you make it clear where the loop starts and where it is going to end. This should only be done if you loop from a lower" part of your tree to a "higher" part several times. If you have a loop running in the same point of the tree, then you may add a loop arrow if you choose, but you don't have to do so. Special Requirements Graded by TAS You must adhere to the style guidelines. (up to 10 points) Your code must meet all of the Special Requirements from the previous Multipath Adventure Lab It is fine if you re-organize your code and have different paths or functions than you did in Lab 4, but make sure that you still meet the requirements as listed in Lab 4. . If you re-organize your code, make sure to also update your Decision Tree Make sure to review the deductions listed in the previous lab and any feedback you received to avoid losing points here. You must have at least 1 for loop in your code (15 points) The for loop must actually be used as a loop, and it must have real effect in your program (it is theoretically possible to use the for loop syntax without actually using it as a loop or creating any real effect, but if you do this you will lose points) You must have at least 1 while loop in your code (15 points) The note on for loops above applies equally to this deduction regarding while loops You must have at least 1 instance of rand() in your code (5 points) Your use of rand() must have real effect in your program (it is possible to use rando to generate a random number without actually using the random number, but if you do this you will lose points)

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!