Programming Assignment #45
Code
/// Name: Dylan Sleeper
/// Period: 6
/// Program Name: Else and If
/// File Name: adventure.java
/// Date Finished: 10/22/2015
import java.util.Scanner;
public class adventure{
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
System.out.println("Narrator: You walk into a room with two doors and you walked through the left one.");
System.out.println("Which door do you go through?");
System.out.println("1) Left 2) Right");
int c1 = keyboard.nextInt();
if(c1 == 1){
System.out.println("Narrator: Wow you actually listened to me... I didn't plan on this... Well how");
System.out.println("about this. You then walk into the room and see a button. You don't push the button,");
System.out.println("and you continue into the next room.");
System.out.println("What do you do?");
System.out.println("1) Walk by the button 2) Defy the Narrator and PRESS IT!");
int c2 = keyboard.nextInt();
if(c2 == 1){
System.out.println("Narrator: Thank goodness you didn't press the button. That could have been");
System.out.println("really, really bad... So now in the next room there is a piece of cake");
System.out.println("on a table. You them proceed to take a bite.");
System.out.println("What do you do?");
System.out.println("1) Take a bite of course 2) Just stand there");
int c3 = keyboard.nextInt();
if(c3 == 1){
System.out.println("Narrator: You then think,\"That was a really good piece of cake.\"");
}
else{
System.out.println("Narrator: You chose the wrong time to stop listening to me. You could've had some");
System.out.println("really good cake. I made it myself.");
}
}
else{
System.out.println("Narrator: Well, well, well... That was a poor choice. You now fall through the floor and");
System.out.println("injur yourself. You then proceed to ask me for help.");
System.out.println("What do you do?");
System.out.println("1) Ask for help 2) Just sit there un defiance.");
int c7 = keyboard.nextInt();
if(c7 == 1){
System.out.println("Narrator: You ask for help and I simply ignore you because you didn't listen when");
System.out.println("I told you not to press the button.");
}
else{
System.out.println("Narrator: Suit yourself I guess. You then just sit there for eternity.");
}
}
}
else{
System.out.println("Narrator: Oh great. I should have known you wouldn't have listened. In the next room");
System.out.println("you see a trap door in floor and you open it and crawl in.");
System.out.println("What do you do?");
System.out.println("1) You go into the trap door 2) You don't move");
int c5 = keyboard.nextInt();
if(c5 == 1){
System.out.println("Narrator: Wow you are a brave soul. Good for you. You now stare down a dark hallway.");
System.out.println("You observe that the hallway is dark and you climb back out of the trap door.");
System.out.println("What do you do?");
System.out.println("1) Climb back out 2) Go down the hallway.");
int c6 = keyboard.nextInt();
if(c6 == 1){
System.out.println("Narrator: You chose the wrong time to start listening to me! You realize the door");
System.out.println("is locked and you just sit there and start to starve. Ha, I win!");
}
else{
System.out.println("Narrator: Wow, you still won't listen. You are the worst character I've ever had");
System.out.println("to narrate for. I just want to let you know. Anyway, you walk down the hallway and");
System.out.println("see a door. You open it and you are finally free. yay. I hope you're happy. Cause");
System.out.println("I'm not.");
}
}
else{
System.out.println("Narrator: Ugh, you are making this a very boring adventure. I guess you then lay down and go");
System.out.println("to sleep. This adventure really couldn't get any lamer.");
System.out.println("What do you do?");
System.out.println("1) Sleep 2) Just keep standing there");
int c8 = keyboard.nextInt();
if(c8 == 1){
System.out.println("Narrator: You then go to sleep and create the worst adventure ever.");
}
else{
System.out.println("Narrator: Wow, you really don't like listening to me, do you. You stand for such a");
System.out.println("long time that you get tired and fall asleep standing up. That's pretty impressive.");
}
}
}
System.out.println("");
System.out.println("The End");
}
}
Outputs