Assignemnt #45 and MyAdventure
Code
/// name: Leila Ordukhani
/// period: 6
/// program name: Thirty-Fourth Program
/// file name: MyAdventure.java
/// date finished: 10/27/15
import java.util.Scanner;
public class MyAdventure
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
String response1, response2, response3, response4, response5, response6, response7;
System.out.println("Leila's Adventure");
System.out.println();
System.out.println("You entetr a haunted house. Do you want to go into the kitchen or upstairs?");
response1 = keyboard.next();
System.out.println();
if (response1.equals("upstairs"))
{
System.out.println("Usptairs you see a hallway. At the end of the hallway is the master bedroom. There is also a bathroom off the hallway. Where would you like to go?");
response2 = keyboard.next();
System.out.println();
if (response2.equals("bathroom"))
{
System.out.println("You made it to the bathroom. Will you step into the shower?");
response3 = keyboard.next();
System.out.println();
if (response3.equals("yes"))
{
System.out.println("You slipped and fell and died in the shower.");
}
else if (response3.equals("no"))
{
System.out.println("You made it to the bathroom. Congradulations.");
}
}
else if (response2.equals("hallyway"))
{
System.out.println("There is a room at the end of the hall. Will you enter?");
response4 = keyboard.next();
System.out.println();
if (response4.equals("yes"))
{
System.out.println("The room is a potal to the underworld. Have fun down there.");
}
else if (response4.equals("no"))
{
System.out.println("The hallyway is endless and you will never reach the end.");
}
}
}
else if (response1.equals("kitchen"))
{
System.out.println("There is a cabinet. Will you open it?");
response5 = keyboard.next();
System.out.println();
if (response5.equals("yes"))
{
System.out.println("There is some food inside. Will you eat it?");
response6 = keyboard.next();
System.out.println();
if (response6.equals("yes"))
{
System.out.println("You died of food poisoning.");
}
else if (response6.equals("no"))
{
System.out.println("You survived food poisoning. Congradulations.");
}
}
else if (response5.equals("no"))
{
System.out.println("You see something move in the corner of your eye. Will you check it out.");
response7 = keyboard.next();
System.out.println();
if (response7.equals("yes"))
{
System.out.println("It was a mouse and it bit your finger off.");
}
else if (response7.equals("no"))
{
System.out.println("It was a ghost and it came and surprise attacked you since you did not investigate.");
}
}
}
System.out.println("That's enough if statements for one day. Hope you enjoyed.");
}
}
Picture of the output