Objective: Write a program that allows the user to play a “Choose Your Own Adven
ID: 3784270 • Letter: O
Question
Objective:
Write a program that allows the user to play a “Choose Your Own Adventure” game. In this game the user will be prompted with making decisions, which will then lead them to different paths with different results.
Requirements:
There must be at least 9 different endings.
To get to each of those 3 endings there must be at least 3 decisions the player has to make to lead you to the end
There may be shorter endings that only have one or two decisions to reach
There must be at least one example of:
Numeric comparison, such as equals to, less than etc.
String comparison
A compound Boolean expression
These do not have to be a part of reaching each ending they just have to be in there somewhere
Be creative!
Explanation / Answer
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "Choose Your Own Adventure: " << endl;
cout << "Water Jungle dMountain"<<endl;
string adv;
cin >> adv;
if (adv == "Water")
{
cout << "Lets go for a swim. Choose your arena " << endl;
cout << "1 Ocean 2 swimming pool"<<endl;
int arena;
cin >> arena;
if (arena == 1)
{
cout << "You are quite adventurous to challenge mighty ocean. You won the dare game." << endl;
}
else
{
cout << "Sorry mate but swimming in swimming pool ain't adventurous. Bye bye"<<endl;
}
}
else
{
if (adv == "Jungle")
{
cout << "Lets go hunting. Choose your weapon." << endl;
cout << "1 gun 2 bow and arrow" << endl;
int weapon;
cin >> weapon;
if (weapon == 1)
{
cout << "You saw a lion. Fire your bullet wisely as you just have 4 of them." << endl;
cout << "As lion leap onto you. How many bullets will you fire on him: ";
int bullets;
cin >> bullets;
if (bullets >= 4)
{
cout << " Oh oo. Nothing left for wolf who leap onto you. Bye bye" << endl;
}
else
{
cout << "Nicely done and killed wolf with remaining bullet. Its time to take your prize back home."<<endl;
}
}
else
{
if (weapon == 2)
{
cout << "You saw a lion. Fire your arrow wisely as you just have 4 of them." << endl;
cout << "As lion leap onto you. How many arrows will you fire on him: ";
int arrows;
cin >> arrows;
if (arrows >= 4)
{
cout << " Oh oo. Nothing left for wolf who leap onto you. Bye bye" << endl;
}
else
{
cout << "Nicely done and killed wolf with remaining arrow. Its time to take your prize back home."<<endl;
}
}
else
{
cout << "Seems like you didn't brought your weapon. You got killed by lion."<<endl;
}
}
}
else
{
if (adv == "Mountain")
{
cout << "Lets reach top of Himalayas." << endl;
cout << "Enter your age: ";
int age;
cin >> age;
if ((age >= 18 && age < 45))
{
cout << "Travel on your quest to mighty mountain" << endl;
}
else
{
if (age < 18)
{
cout << "Sorry kids not allowed. Do it in your youth" << endl;
}
else
{
cout << "Sorry grandpa. You should have done it in your youth" << endl;
}
}
}
else
{
cout << "You doesn't seems to be adventurous. Bye bye ";
}
}
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.