A Little Quiz

Code

    /// Name: Rachel Smith
    /// Period: 5
    /// Program Name: A Little Quiz
    /// File Name: ALittleQuiz.java
    /// Date Finished: 10/9/2015
    
    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 came first, the chicken or the egg?" );
            System.out.println( "\t 1) the chicken" );
            System.out.println( "\t 2) the egg" );
            System.out.print( "> " );
            q1 = keyboard.nextInt();
            
            if ( q1 == 1 ) {
                System.out.println( "No! It had to come from somewhere!" );
            }
            else if ( q1 == 2 ) {
                System.out.println( "Thank you. Somebody with some sense." );
            }
            else {
                System.out.println( "That's not even a choice." );
            }
            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 ( q1 == 1 ) {
                System.out.println( "Good. That means your eyes function properly." );
            }
            else if ( q1 == 2 ) {
                System.out.println( "No! There was just a shadow on it!" );
            }
            else {
                System.out.println( "That's not even a choice." );
            }
            System.out.println();
            
            System.out.println( "(Q3) Is destiny fated or do we have free will?" );
            System.out.println( "\t 1) destiny is fated" );
            System.out.println( "\t 2) we have free will" );
            System.out.print( "> " );
            q3 = keyboard.nextInt();
            
            if ( q1 == 1 ) {
                System.out.println( "I hate to break it to you Calvinists out there but life isn't predestined." );
            }
            else if ( q1 == 2 ) {
                System.out.println( "Damn right we do." );
            }
            else {
                System.out.println( "That's not even a choice." );
            }
            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!" );
            
        }
    }

    

Picture of the output

Assignment 1