Assignemnt #35 A Little Quiz
Code
///Name: JJ Deng
///Period: 6
///Program Name: A Little Quiz
///File Name: ALittleQuiz.java
///Date Finished: 10/27/15
import java.util.Scanner;
public class ALittleQuiz
{
public static void main( String[] args )
{
Scanner ALQ = new Scanner(System.in);
double Qone, Qtwo, Qthree, count;
count = 0;
System.out.println("Are you ready for a quiz?");
ALQ.next();
System.out.println("OK, HERE IT COMES ANYWAYS!");
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.println(">");
Qone = ALQ.nextDouble();
if ( Qone == 3)
{
System.out.println("That's right");
count++;
}
else if ( Qone == 2 )
{
System.out.println("You missed, the Capital of Alaska is Juneau");
}
else
{
System.out.println("You missed, the Capital of Alaska is Juneau");
}
System.out.println(" Q2) 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.println(">");
Qtwo = ALQ.nextDouble();
if (Qtwo == 1)
{
System.out.println("Sorry, the word cat is a string. ints can only store numbers.");
}
else
{
System.out.println("That's right!");
count++;
}
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.println(">");
Qthree = ALQ.nextDouble();
if (Qthree == 2)
{
System.out.println("That's right!");
count++;
}
else
{
System.out.println("No, the answer is number 2");
}
System.out.println("Overall, you got "+ count +" out of 3 correct.");
System.out.println("Thanks for playing");
}
}
Picture of the output