Assignment #39

Code

    ///Name: Cody Swain
    ///Period: 6
    ///Project Name: Quiz
    ///File Name: Quiz.java
    ///Date: 10/15/15
    
    import java.util.Scanner;
    
    public class Quiz
    {
        public static void main( String[] args )
        {
            Scanner keyboard = new Scanner(System.in);
            int answer1, answer2, answer3;
            int numberCorrect = 0;
    
            System.out.println();
            System.out.println( "Are you ready for a quiz? [hit y]" );
            keyboard.next();
            System.out.println( "Okay, here it comes!" );
            System.out.println();
    
            System.out.println( "Q1) What is 5 + 5 * 2 / 5 ? ");
            System.out.println( "        1) 3 " );
            System.out.println( "        2) 4 " );
            System.out.println( "        3) 5 " );
            System.out.println();
            answer1 = keyboard.nextInt();
            System.out.println();
    
            if ( answer1 == 1)
            {
                numberCorrect += 1;
                System.out.println( "That's right! ");
            }
            else
                System.out.println( "Incorrect; maybe check your order of operations. " );
            System.out.println();
    
    
    
            System.out.println( "Q2) What is the acceleration due to gravity near the earth? ");
            System.out.println( "        1) 8.79  [m/s^2] " );
            System.out.println( "        2) 9.81  [m/s^2] " );
            System.out.println( "        3) 19.83 [m/s^2] " );
            System.out.println();
            answer2 = keyboard.nextInt();
            System.out.println();
    
            if ( answer2 == 2)
            {
                numberCorrect += 1;
                System.out.println( "That's right! ");
            }
            else
                System.out.println( "Incorrect; It is 9.81 [m/s^2] " );
            System.out.println();
    
    
            System.out.println( "Q3) What shape is the earth? ");
            System.out.println( "        1) Cube " );
            System.out.println( "        2) Sphere " );
            System.out.println( "        3) Prism " );
            System.out.println();
            answer2 = keyboard.nextInt();
            System.out.println();
    
            if ( answer2 == 2)
            {
                numberCorrect += 1;
                System.out.println( "That's right! ");
            }
            else
                
                System.out.println( "Incorrect; You are stupid " );
            System.out.println();
    
    
    
            System.out.println( "Overall, you got " + numberCorrect + " out of 3 correct. " );
            System.out.println( "Thanks for playing!" );
        }
    }

        
    

Picture of the output

Assignment 39