Assignment #45: Choose Your Own Adventure

Code

/// Name: Kiran O'Farrell
/// Program name: Choose Your Own Adventure
/// File name: ChooseYourOwnAdventure.java
/// Date completed:


import java.util.Scanner;

public class ChooseYourOwnAdventure {

    public static void main (String[] args) {
    
    Scanner keyboard = new Scanner(System.in);
    
    String choice1, choice2, choice3;
    
    System.out.println("Welcome to Choose Your Own Adventure!");
    System.out.println("You come to a fork in the road. You can go LEFT or RIGHT. Which way do you go?");
    choice1 = keyboard.next();
    
        if (choice1.equals("left")) {
    
        System.out.println("You are walking on a beach. You come across a shipwreck. Do you enter the HOLD or the CABIN?");
        choice2 = keyboard.next();
    
            if (choice2.equals("hold")) {
    
            System.out.println("You are in the ship's hold. You see an ornately carved chest, but the way to it is blocked by a fallen beam. Do you FIND another path or LEVER it out of the way?");
            choice3 = keyboard.next();
            
                if (choice3.equals("find")) {
                
                System.out.println("You find your way around the beam to the chest. It slowly creaks open to reveal...");
                System.out.println("TO BE CONTINUED...maybe");
                
                }
            
                else if (choice3.equals("lever")) {
                
                System.out.println("The roof collapses! You are instantly crushed.");
                System.out.println("THE END");
            
                }
                
            }
    
            else if (choice2.equals("cabin")) {
        
            System.out.println("You are in the captain's cabin. You see a dagger with a jeweled hilt and a strongbox with a broken lock. Do you TAKE the dagger or OPEN the strongbox?");
            choice3 = keyboard.next();
            
                if (choice3.equals("take")) {
                
                System.out.println("You pricked yourself on the captain's poisoned dagger. Oops...");
                System.out.println("THE END");
                
                }
            
                else if (choice3.equals("open")) {
                
                System.out.println("You open the strongbox and find...");
                System.out.println("TO BE CONTINUED...maybe");
                
                }
            
            }
            
        }
    
        else if (choice1.equals("right")) {
    
        System.out.println("You are walking through a forest. You come upon another fork in the road. Do you go down the LEFT path or the RIGHT           path?");
        choice2 = keyboard.next();
        
            if (choice2.equals("left")) {
            
            System.out.println("You see a dark cave. Do you ENTER the cave or CONTINUE on?");
            choice3 = keyboard.next();
            
                if (choice3.equals("enter")) {
                
                System.out.println("You are eaten by a grue.");
                System.out.println("THE END");
                
                }
            
                else if (choice3.equals("continue")) {
                
                System.out.println("You continue your journey into the forest...");
                System.out.println("TO BE CONTINUED...maybe");
                
                }
                
            }
            
            else if (choice2.equals("right")) {
            
            System.out.println("You come to a cliff with a rope bridge over it. Do you try to CROSS the chasm or CONTINUE on?");
            choice3 = keyboard.next();
            
                if (choice3.equals("cross")) {
                
                System.out.println("The bridge gives way. You fall to your death.");
                System.out.println("THE END");
                
                }
            
                else if (choice3.equals("continue")) {
                
                System.out.println("You continue your journey into the forest...");
                System.out.println("TO BE CONTINUED...maybe");
                
                }
            
            }
    
        }
    
    }
    
}
    

Picture of the output