Question

In: Computer Science

PLEASE DO THIS IN C#: Back in my Day! Kids who grew up in the late...

PLEASE DO THIS IN 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.

Solutions

Expert Solution

Pseudocode:

This program continues a story according to the user's input

In the main function

print prompt "It is a dark and stormy night. Do you want to take an umbrella? (Y/N):"

Label bose:

Take the input from user

if user input is equal to string Y

then print prompt "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):"

label tagore:

Take the input from user

if user input is equal to string F

then print prompt "You take out your umbrella and jab it into the wolf's paw! It runs away and you live another day."

else if user input is equal to string R

then print prompt " 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."

else

then print prompt "!!ERROR!! PLEASE ENTER F/R"

passing control to the label tagore.

else if user input is equal to string N

then print prompt "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)"

label tagore:

Take the input from user

if user input is equal to string F

then print prompt "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."

else if user input is equal to string R

then print prompt "You were unable to outrun the wolf and he enjoyed his meal"

else

then print prompt "!!ERROR!! PLEASE ENTER F/R"

passing control to the label tagore.

  

else

then print prompt "!!ERROR!! PLEASE ENTER Y/N"

passing control to the label bose.

  

*****************C# code******************

using System;


namespace Story
{
public class Storygame
{
public static void Main(string[] args)
{
String c; // declaring string variable
Console.WriteLine("It is a dark and stormy night. Do you want to take an umbrella? (Y/N):"); //output on console
           bose: //label for goto command for bose
c = Console.ReadLine(); //storing input in c variable
if(Equals(c,"Y")) //checking equality of the strings
{
Console.WriteLine("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):");
tagore: //label for goto command for tagore
           c=Console.ReadLine(); //storing input in c variable
           if(Equals(c,"F"))
               Console.WriteLine(" You take out your umbrella and jab it into the wolf's paw! It runs away and you live another day.");
               else if(Equals(c,"R"))
                   Console.WriteLine(" 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.");
           else
               {
                   Console.WriteLine("!!ERROR!! PLEASE ENTER F/R");
                   goto tagore; //reverting back to label tagore using goto keyword
               }
       }
           else if(Equals(c,"N"))
           {
               Console.WriteLine("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)");
               tagore:
               c=Console.ReadLine();
               if(Equals(c,"F"))
                   Console.WriteLine("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.");                      
               else if(Equals(c,"R"))
                   Console.WriteLine("You were unable to outrun the wolf and he enjoyed his meal");
               else
               {
                   Console.WriteLine("!!ERROR!! PLEASE ENTER F/R");
                   goto tagore;
               }
           }
          
           else
               {
                   Console.WriteLine("!!ERROR!! PLEASE ENTER Y/N");
                   goto bose; //reverting back to label bose using goto keyword
               }
          
}
}
}

Output:

**********NOTE**********

we use goto command for control passing(advised to be not used in complex project)

Equals(c,"R")- equals here is being used  
In C#, Equals(String, String) is a String method to compare strings

******** If this answer helps YOU PLEASE LIKE ThankYou********

It is a dark and stormy night. Do you want to take an umbrella? (Y/N): 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 umb F You take out your umbrella and jab it into the wolf's paw! It runs away and you live another day


Related Solutions

The home where I grew up was purchased by my father for $3,200 in the year...
The home where I grew up was purchased by my father for $3,200 in the year 1943. As of the year 2012, its market value was $850,000. Using the concepts of purchasing power, inflation, and price indexes how would you explain this tremendous increase in value? Are there any other possible outside factors besides the above which might also help explain the increase?
So Bob and Terry are friends who grew up in California. There is a free ticket...
So Bob and Terry are friends who grew up in California. There is a free ticket to Coachella near Indio being offered by a radio station. Both friends call in separately and the radio station tell them that they won it. A Coachella ticket can cost anywhere from $600 for GA ( general admission) all the way to $2000 for VIP per person. Getting one of those tickets is quite expensive! So Bob and Terry both go down to the...
A childcare centre adopts a strict late pickup policy. Parents who picked up their children late...
A childcare centre adopts a strict late pickup policy. Parents who picked up their children late will be charged $1 per minute (assuming no rounding here, e.g., a late of 1.235 minutes will be charged $1.235). Bob is a parent who is always late, and each day the amount of time in minutes he is late follows an exponential distribution with mean 1. Further assume that the time he is late is always independent from day to day. His child...
Patricia is 32 years old and she grew up in a Catholic family, who observed strict...
Patricia is 32 years old and she grew up in a Catholic family, who observed strict traditions. Patricia is a devout Catholic and she attends church every week. She teaches at Sunday school and often helps with local fundraising activities for the church when asked to by the local priest. She lives in a unit with her husband Harry. Patricia has only had one sexual partner because she did not believe in sex before marriage. They were married eight years...
PLEASE DO THIS IN C#Design and implement a programming (name it NextMeeting) to determine the day...
PLEASE DO THIS IN C#Design and implement a programming (name it NextMeeting) to determine the day of your next meeting from today. The program reads from the user an integer value representing today’s day (assume 0 for Sunday, 1 for Monday, 2 for Tuesday, 3 for Wednesday, etc…) and another integer value representing the number of days to the meeting day. The program determines and prints out the meeting day. Format the outputs following the sample runs below. Sample run...
Red Yoder is an 80-year-old farmer who lives alone in the farmhouse where he grew up....
Red Yoder is an 80-year-old farmer who lives alone in the farmhouse where he grew up. It is located 20 miles outside of town. Red has been a widower for 10 years. Red rarely cooks for himself and mainly eats packaged or processed foods. His son, Jon, manages the farm now, but Red is still involved in the decision making.Red’s current medical problems include insulin-dependent diabetes complicated by an open foot wound. He also has some incontinence and difficulty sleeping....
A dog barks outside my window as I sleep, but I do not wake up. My...
A dog barks outside my window as I sleep, but I do not wake up. My wife then whispers my name and I wake up with a start. Why does this happen?
I wrote my start-up business plan for entrepreneurship class. Please loot at the my outline and...
I wrote my start-up business plan for entrepreneurship class. Please loot at the my outline and figure out what I don't have or What I can add more, and write about the part in detail. Executive Summary According to Wisconsin Farming bureau there are 77,000 farms in Wisconsin with a total of 14.4 million acres of land and agriculture in Wisconsin provides $88.3 billion to the states economy. With the advent of the organic foods trend younger households have seen...
In Hawaii, With inter-island travel opening back up on June 16 but 14-day travel quarantine from...
In Hawaii, With inter-island travel opening back up on June 16 but 14-day travel quarantine from outside of Hawaii still in place, how important is Kamaaina Pricing (residence pricing) to rejuvenate the economy? Please use "external factors affecting pricing decisions" to explain how hospitality/travel companies will be setting their prices.
Hello this is for C++ language. I am currently stuck on creating my api for Day...
Hello this is for C++ language. I am currently stuck on creating my api for Day Trading Stocks. as follows I need an api for *//Function Signature * * parameter: * * Return Value: ** *// Write the following function taking in an integer vector (vector &prices) consisting of all prices, in chronological order, for an hypothetical instrument. Your function recommends the maximum profit an investor can make by placing AT MOST one buy and one sell order in the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT