Assignemnt #35
Code
/// Name: Sam Wilson
/// Period: 6
/// Program Name: quiz
/// File Name: quiz.java
/// Date Finished: 10/13/2015
import java.util.Scanner;
public class quiz
{
public static void main( String[] args )
{
Scanner key = new Scanner(System.in);
double qOne, qTwo, qThree;
int count;
count = 0;
System.out.print("Are you ready for a quiz? ");
key.next();
System.out.println("Ok 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("> ");
qOne = key.nextDouble();
if ( qOne == 3)
{
System.out.println("You are Correct!");
count++;
}
else if ( qOne == 1)
{
System.out.println("I'm Sorry That is the wrong answer");
}
else if ( qOne == 2)
{
System.out.println("I'm Sorry That is the wrong answer");
}
else
{
System.out.println("You failed to pick one of the three choices, Great Job!");
}
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("> ");
qTwo = key.nextDouble();
if ( qTwo == 2)
{
System.out.println("You are Correct!");
count++;
}
else if ( qTwo == 1)
{
System.out.println("I'm Sorry That is the wrong answer, \"Cat\" is a string");
}
else
{
System.out.println("You failed to pick one of the two choices, Great Job!");
}
System.out.println();
System.out.println("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("> ");
qThree = key.nextDouble();
if ( qThree == 2)
{
System.out.println("You are Correct!");
count++;
}
else if ( qThree == 1)
{
System.out.println("I'm Sorry That is the wrong answer");
}
else
{
System.out.println("You failed to pick one of the two choices, Great Job!");
}
System.out.println();
System.out.println("You got "+ count +" out of 3 correct");
}
}
Picture of the output