Assignemnt #45 Choose Your Own Adventure
Code
///Name: Joshua Pell
///Period: 6
///Project Name: Choose Your Own adventure
///File Name: adventure.java
///Date: 10/29/2015
import java.util.Scanner;
public class adventure
{
public static void main( String[] args)
{
Scanner keyboard = new Scanner(System.in);
String ans1,ans2,ans3,ans4;
System.out.println("You are in a creepy house. Would you like to go upstairs or into the kitchen?");
ans1 = keyboard.next();
if (ans1.equals("upstairs"));
{
System.out.println("You go upstairs. There is a door. Do you go through?");
ans2 = keyboard.next();
if (ans2.equals("yes"));
{
System.out.println("You go in the room. It is too dark to see anything. Do you turn on the light?");
ans3 = keyboard.next();
if (ans3.equals("yes"))
{
System.out.println("You turn on the light. It is a normal room. You leave.");
}
if (ans3.equals("no"))
{
System.out.println("You walk into the room and stub your toe. You fall down never to get up again");
}
}
if (ans2.equals("no"))
{
System.out.println("You Continue down the hallway. There is a window at the end. Do you jump out?");
ans3 = keyboard.next();
if (ans3.equals("yes"))
{
System.out.println("You jump out the window. Luckily there is a trampoline. You escape from the creepy house.");
}
if (ans3.equals("no"))
{
System.out.println("You make probably the smart decision and go back to the front door and leave");
}
if (ans1.equals("kitchen"))
{
System.out.println("You enter the kitchen. You are hungry. Do you search for food?");
ans2 = keyboard.next();
if (ans2.equals("yes"))
{
System.out.println("You look for something to eat. You find some toast. Do you eat it?");
ans3 = keyboard.next();
}
if (ans3.equals("yes"))
{
System.out.println("You forgot you're allergic to toast. You die.");
}
if (ans3.equals("no"))
{
System.out.println("You die of starvation.");
}
if (ans2.equals("no"))
{
System.out.println("Are you sure? You're really hungry.");
ans3 = keyboard.next();
}
if (ans3.equals("yes"))
{
System.out.println("You die of starvation.");
}
if (ans3.equals("no"))
{
System.out.println("It's too late. You die of starvation anyway.");
}
}
}
}
}
}
Picture of the output