PROGRAMMING AND CODE


Assignemnt #45

Code

/// Name: Justin Li
/// Period 7
/// Program Name: ChooseYourOwnAdventure
/// File Name: ChooseYourOwnAdventure.java
/// Date Finished: 11/16/15

import java.util.Scanner;

class ChooseYourOwnAdventure {
  
    public static void main(String[]args) {
      
        Scanner keyboard = new Scanner(System.in);
        
        String one, two, three;
        
        System.out.println("WELCOME TO SPOOKY HOUSE");
        System.out.println("\nThere are two doors. Do you choose the 'red' door or the 'blue' door?");
        one = keyboard.next();
        
        if (one.equals("blue")) {
            System.out.println("\n\nThere are two doors. Do you choose the 'black' door or the 'grey' door?");
            two = keyboard.next();
            
            if (two.equals("black")) {
                System.out.println("\n\nThere are two doors. Do you choose the 'white' door or the 'green' door?");
                two = keyboard.next();
                
                if (two.equals("white")) {
                    System.out.println("\n\nWelp, you entered the white door.");
                    two = keyboard.next();
                }
                else if (two.equals("green")) {
                    System.out.println("\n\nWelp, you entered the green door.");
                    two = keyboard.next();
                } 
            }
            else if (two.equals("grey")) {
                System.out.println("\n\nThere are two doors. Do you choose the 'cheese' door or the 'pear' door?");
                two = keyboard.next();
                
                if (two.equals("cheese")) {
                    System.out.println("\n\nWelp, you entered the cheese door.");
                    two = keyboard.next();
                }
                else if (two.equals("pear")) {
                    System.out.println("\n\nWelp, you entered the pear door.");
                    two = keyboard.next();
                }
            }
            
            else {
                System.out.println("\n\nWHAT??");
                
            }
        }
        else if (one.equals("red")) {
            System.out.println("\n\nThere are two doors. Do you choose the 'apple' door or the 'windows' door?");
            two = keyboard.next();
            
            if (two.equals("windows")) {
                System.out.println("\n\nThere are two doors. Do you choose the 'dude' door or the 'rude' door?");
                two = keyboard.next();
                
                if (two.equals("dude")) {
                    System.out.println("\n\nWelp, you entered the dude door.");
                    two = keyboard.next();
                }
                else if (two.equals("rude")) {
                    System.out.println("\n\nWelp, you entered the rude door.");
                    two = keyboard.next();
                } 
            }
            else if (two.equals("apple")) {
                System.out.println("\n\nThere are two doors. Do you choose the 'martini' door or the 'soda' door?");
                two = keyboard.next();
                
                if (two.equals("martini")) {
                    System.out.println("\n\nWelp, you entered the martini door.");
                    two = keyboard.next();
                }
                else if (two.equals("soda")) {
                    System.out.println("\n\nWelp, you entered the soda door.");
                    two = keyboard.next();
                }
            }
            
            else {
                System.out.println("\n\nWHAT??");
                
            }
        }
        
        
            
           
          
          
    }
}
    

Picture of the output

Assignment 1