Assignment #39

Code

/// Name: Jonathan Stine
/// Period: 5
/// Program Name: A Little Quiz
/// File Name: ALittleQuiz.java
/// Date Finished: 1/19/16
    
    import java.util.Scanner;
    
    public class ALittleQuiz {
        
        public static void main( String[] args ) {
            
            Scanner keyboard = new Scanner(System.in);
            
            int q1, q2, q3, n;
            
            System.out.println( "Are you ready for a little quiz? " );
            System.out.println( "Okay, here it comes!" );
            
            System.out.println();
            System.out.println( "(Q1) Which is bigger, 5 or 6?" );
            System.out.println( "\t 1) 5! (I'm an idot)" );
            System.out.println( "\t 2) 6." );
            System.out.print( "> " );
            q1 = keyboard.nextInt();
            
            if ( q1 == 1 ) {
                System.out.println( "No! " );
            }
            else if ( q1 == 2 ) {
                System.out.println( "That was hard wasn't it? Good job." );
            }
            else {
                System.out.println( "Try again bozo!" );
            }
            System.out.println();
            
            System.out.println( "(Q2) Is the dress black and blue or white and gold?" );
            System.out.println( "\t 1) white and gold" );
            System.out.println( "\t 2) black and blue" );
            System.out.print( "> " );
            q2 = keyboard.nextInt();
            
            if ( q2 == 1 ) {
                System.out.println( "Good. " );
            }
            else if ( q2 == 2 ) {
                System.out.println( "Nope, you idiot!" );
            }
            else {
                System.out.println( "That's not even a choice." );
            }
            System.out.println();
            
            System.out.println( "(Q3) If you win the lotto what do you do?" );
            System.out.println( "\t 1) CLAIM IT IMMEDIATELY!" );
            System.out.println( "\t 2) Get a lawyer and claim it anonymously through an LLC" );
            System.out.print( "> " );
            q3 = keyboard.nextInt();
            
            if ( q3 == 1 ) {
                System.out.println( "Wrong, also, did you know that lottery winners who go public face a sucide rate 100x higher than normal?" );
            }
            else if ( q3 == 2 ) {
                System.out.println( "That's the smart decision!" );
            }
            else {
                System.out.println( "Do you know how to follow basic instructions?" );
            }
            System.out.println();
            
            n = 0;
            
            if ( q1 == 1 && q2 == 1 && q3 == 1) {
                n = 1;
            }
            else if ( q1 == 1 && q2 == 2 && q3 == 1) {
                n = 0;
            }
            else if ( q1 == 1 && q2 == 2 && q3 == 2) {
                n = 1;
            }
            else if ( q1 == 1 && q2 == 1 && q3 == 2) {
                n = 2;
            }
            else if ( q1 == 2 && q2 == 1 && q3 == 1) {
                n = 2;
            }
            else if ( q1 == 2 && q2 == 2 && q3 == 1) {
                n = 1;
            }
            else if ( q1 == 2 && q2 == 2 && q3 == 2) {
                n = 2;
            }
            else if ( q1 == 2 && q2 == 1 && q3 == 2) {
                n = 3;
            }
            else {
                System.out.println( "Since you didn't take the quiz seriously you will get no credit." );
            }
            System.out.println( "Overall, you got " + n + " out of 3 correct." );
            System.out.println( "Thanks for playing!" );
            
        }
    }
    
 
    

Code Output