Assignment #39 ALittleQuiz

Code

    /// Name: Matthew Lorence
    /// Period: 5
    /// Program Name: ALittleQuiz
    /// File Name: ALittleQuiz.java
    /// Date Finished:12/01/15
    
    import java.util.Scanner;

    public class ALittleQuiz
    {
        public static void main( String[] args )
        {
            String ready;
            int capital, cat, math, score = 0;
        
            Scanner keyboard = new Scanner(System.in);
            
            System.out.print( "Are you ready for a quiz? " );
            ready = keyboard.next();
            
            System.out.println( "Okay, here it comes!" );
            System.out.println();
            System.out.println( "Q1) What is the capital of Alaska?" );
            System.out.println( "   1) Melbourne" );
            System.out.println( "   2) Anchorage" );
            System.out.println( "   3) Juneau");
            System.out.println();
            System.out.print( "> " );
            capital = keyboard.nextInt();
            System.out.println();
            
            if ( capital == 3 )
            {
                System.out.println( "That's right!");
                score++;
            }
            
            else
            {
                System.out.println( "THAT'S WRONG!");
            }
            
            System.out.println();
            System.out.println( "Can you store the value \"cat\" in a variable of type int?" );
            System.out.println( "   1) Yes" );
            System.out.println( "   2) No" );
            System.out.println();
            System.out.print( "> " );
            cat = keyboard.nextInt();
            System.out.println();
            if ( cat == 2 )
            {
                System.out.println( "That's right!");
                score++;
            } 
            
            else
            {
                System.out.println( "Sorry, \"cat\" is a string. ints can only store numbers." );
            }
            
            System.out.println();
            System.out.println( "Q3) What is the result of 9+6/3?" );
            System.out.println( "   1) 5" );
            System.out.println( "   2) 11" );
            System.out.println( "   3) 15/3" );
            System.out.println();
            System.out.print( "> " );
            math = keyboard.nextInt();
            System.out.println();
            
            if ( math == 2 )
            {
                System.out.println( "That's right!");
                score++;
            } 
            
            else
            {
                System.out.println( "THAT'S WRONG!!!" );
                
            }
            System.out.println();
            System.out.println();
            System.out.println("You got " + score + " correct!");
            System.out.println( "Thanks for playing! ");
           
            
           
        }
    }
        
        
    

Picture of the output

Assignment 39