In: Computer Science
PLEASE CREATE A PROGRAM IN PSEUDOCODE AND C#
Back in my Day! Kids who grew up in the late 70s didn’t have a lot of options for video games, but they did have “Choose your own Adventure” books. These books were cool and let the reader make meaningful decisions. If they chose choice “A”, they would turn to a page of the book and continue their adventure. If they chose choice “B”, they would turn to a different page and read a different adventure. Your task is to design (pseudocode) and implement (source code) for a story that has four different outcomes based on two different user inputs. See appendix for checking string equality.
Sample run 1:
It is a dark and stormy night. Do you want to take an umbrella? (Y/N): Y
Good - you have an umbrella.
You start to walk down a path and hear a scream. You realize that the person screaming is YOU because you see a wolf! Do you fight with your umbrella or run? ((F)ight/(R)un): F
You take out your umbrella and jab it into the wolf's paw! It runs away and you live another day.
Sample run 2:
It is a dark and stormy night. Do you want to take an umbrella? (Y/N): Y
Good - you have an umbrella.
You start to walk down a path and hear a scream. You realize that the person screaming is YOU because you see a wolf! Do you fight with your umbrella or run? ((F)ight/(R)un): R
You begin running so fast, the umbrella opens and you fly away like Mary Poppins. You're a little embarrassed, but you see the wolf fading off in the distance.
Sample run 3:
It is a dark and stormy night. Do you want to take an umbrella? (Y/N): N
You decide not to take an umbrella.
You start to walk down a path and hear a scream. You realize that the person screaming is YOU because you see a wolf! Do you fight with your hands or run? ((F)ight/(R)un): F
You begin fighting the wolf only to realize you had just eaten a McGrease® meal earlier. You fall dead from rigorous exercise, having had a heart attack.
Sample run 4:
It is a dark and stormy night. Do you want to take an umbrella? (Y/N): N
You decide not to take an umbrella.
You start to walk down a path and hear a scream. You realize that the person screaming is YOU because you see a wolf! Do you fight with your hands or run? ((F)ight/(R)un): R
Are you serious? You can't outrun a wolf! The wolf catches you and you are somewhat relieved because you don't have to worry about that Calculus exam…
Thanks for the question. Here is the code for the 3 scenarios. There should be another scenario when the user choose not to take the umbrella and decided to run. This scenario is missing.
Let me know for any help in comments !!
thanks a lot : )
=================================================================
#include<iostream>
#include<string>
using std::cout;
using std::cin;
using std::endl;
using std::string;
int main(){
string choice;
cout<<"It is dark and stormy night. Do you want to take an
umbrella? (Y/N): ";
cin>>choice;
if(choice.compare("N")==0){
cout<<"You decide not to take an
umbrella.\n";
}else{
cout<<"Good - you have an
umbrella.\n";
}
string fight;
cout<<"You start to walk down a path and hear a scream. You
realize that the person"
<<endl<<"screaming is YOU because you see a wolf! Do
you fight with your umbrella or"
<<endl<<" run? (F)ight/(R)un): ";
cin>>fight;
if(choice.compare("Y")==0 && fight.compare("F")==0){
cout<<endl
<<"You take out your umbrella and jab it into the wolf\'s
paw! It runs"
<<"away and you live another day"<<endl;
}else if(choice.compare("Y")==0 &&
fight.compare("R")==0){
cout<<endl
<<"You begin running so fast, the umbrella opens and you fly
away like Mary"
<<endl<<"Poppins. You\'re a little embarassed, but you
see the wolf fading off in the"
<<endl<<"in the distance."<<endl;
}else if(choice.compare("N")==0 &&
fight.compare("F")==0){
cout<<endl
<<"You begin fighting the wolf only to realize you had just
eaten a McGrease meal"
<<endl<<"earlier. You fall dead from rigorous exercise,
having had a heart attack."<<endl;
}else{
cout<<"Are you serious? You can't outrun a wolf! The wolf catches you and you are somewhat relieved\nbecause you don't have to worry about that Calculus exam"<<endl;
}
}
=======================================================================