Question
What functions can I add to this code?? The insturctions are below and my code is below the instructions Modify your Multipath Adventure from the
What functions can I add to this code??
The insturctions are below and my code is below the instructions
Modify your Multipath Adventure from the previous lab to fulfill the following requirements:
- Use at least 3 functions
- At least one function needs to have at least 2 parameters
- At least one function needs to return a value
(If your code already fulfilled these requirements, then you can resubmit the same code here, take the Canvas quiz, and 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 (e.g. loops, etc.). 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.
Hints: Possible uses of functions might include a GetUserChoice function that handles string processing, functions to print text that is repeated in multiple branches, or functions that represent the different paths you might take.
Deductions Graded by TAs
- Adherence to the style guidelines. (up to 10 points)
- You must have at least 3 functions in your code (5 points per missing function)
- You must have at least 1 function that has at least 2 parameters (15 points)
- You must have at least 1 function that returns a value (15 points)
- Your code must correctly follow the paths outlined in your decision tree (15 points per path that does not work correctly)
- This includes terminating properly at the end of a path - if you need to end the program early at any point in your code, you can use the command exit(0); to end your program at any point
#include
int main () { string choice1; string choice2; string choice3; string choice4; string choice5; cout << "You wake up in the morining knowing you have football practice after school, so you decide to... " << endl; cout << "a. Get ready and skip breakfast." << endl; cout << "b. Eat breakfast knowing that it fuels your body." << endl; cin >> choice1; if (choice1 == "a") { cout << "You drive to school hungry and it gets to lunch time and you're starving. You decide to... " << endl; cout << "a.Eat until you are full." << endl; cout << "b. Eat a moderate amount." << endl; cin >> choice4; } if (choice4 == "a") { cout << "You arrive at practice while you are full so you decide to..." << endl; cout << "a. Tell Coach G that you are sick." << endl; cout << "b. Practice." << endl; cin >> choice5; } if (choice5 == "a") { cout << " You get to go home. THE END." << endl; } else { cout << "You end up throwing up then you go home. THE END." << endl; } if (choice5 == "a") { cout << "end" << endl; } else { cout << "You don't have enough energy because you are hungry and pass out during practice."; cout << "You then end up going home. THE END." << endl; } if (choice1 == "a") { cout << endl; } else { cout << "You get in the car to drive to school, you feel good. "; cout << "Time passes and now it is lunch time and you are not hungry. You decide to... " << endl; cout << "a. Eat moderatley. " << endl; cout << "b. Not eat at all." << endl; cin >> choice2; if (choice2 == "b") { cout << "You don't have enough energy to practice. So you decide to..." << endl; cout << "a. Practice." << endl; cout << "b. Go home." << endl; cin >> choice3; if (choice3 == "b") { cout << "You pass out." << endl; } else { cout << "You feel good." << endl; } } else { cout << "You have a good practcie." << endl; } } }
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