Assignment 39

 import java.util.Scanner;
 
 public class Quiz
 {
     public static void main( String[] args )
     {
         Scanner keyboard = new Scanner(System.in);
 
         int answer1, answer2, answer3, score;
         String dummy;
         
         score = 0;
 
         System.out.print("Are you ready for a quiz? ");
         dummy = keyboard.next();
         
         System.out.println("Q1) What is the capital of Alaska?\n\t1) Melbourne\n\t2) Anchorage\n\t3) Juneau\n");
         System.out.print(">");
         answer1 = keyboard.nextInt();
         
         if (answer1 == 3)
         {
         System.out.println("\nCorrect!\n");
         score++;
         }
         else
         {
         System.out.println("\nIncorrect. Juneau is the capital of Alaska\n");
         }
         
         
         System.out.println("Q2) Can you store the value \"cat\" in a variable of type int?\n\t1) yes\n\t2) no\n");
         System.out.print(">");
         answer2 = keyboard.nextInt();
         
         if (answer2 == 2)
         {
         System.out.println("\nCorrect!\n");
         score++;
         }
         else
         {
         System.out.println("\nIncorrect. An int can only store a number.\n");
         }
         
         
         System.out.println("Q3) What is the result of 9+6/3?\n\t1) 5\n\t2) 11\n\t3) 15/3\n");
         System.out.print(">");
         answer3 = keyboard.nextInt();
         
         if (answer3 == 2)
         {
         System.out.println("\nCorrect!\n");
         score++;
         }
         else
         {
         System.out.println("\nIncorrect. 9+6/3=11.\n");
         }
         
         System.out.println("\nOverall, you got " +score+ " out of 3 correct. \nThanks for playing!");
     }
 }