Assignment #39 and Little Quiz
Code
/// Name: Graham Pollock
/// Period: 5
/// Program Name: A Little Quiz
/// File Name: LittleQuiz.java
/// Date Finished: 10/27/2015/
import java.util.Scanner;
public class LittleQuiz
{
public static void main( String[] agrs )
{
Scanner keyboard = new Scanner(System.in);
System.out.print( "Are you ready for a Quiz? ");
String ready = keyboard.next();
int answer;
int numberofquizes = 3;
int correct = 0;
int q1a1 = 1;
int q1a2 = 2;
int q1a3 = 3;
int q2a1 = 1;
int q2a2 = 2;
int q3a1 = 1;
int q3a2 = 2;
int q3a3 = 3;
System.out.println("Okay, here it comes!");
System.out.println("");
System.out.println("Q1) What is the capital of South Korea?");
System.out.println(" "+ q1a1 +") Beijing");
System.out.println(" "+ q1a2 +") Hanoi");
System.out.println(" "+ q1a3 +") Seoul");
System.out.print("Your answer: ");
answer = keyboard.nextInt();
if (answer == 1)
{
System.out.println("Incorrect!");
}
else if (answer == 2)
{
System.out.println("Incorrect!");
}
else if (answer == 3)
{
System.out.println("That's right!");
correct = correct + 1;
}
System.out.println();
System.out.println("Q2) Ice is made out of glass.");
System.out.println(" "+ q2a1 +") True");
System.out.println(" "+ q2a2 +") False");
System.out.print("Your answer: ");
answer = keyboard.nextInt();
if (answer == 1)
{
System.out.println("Incorrect!");
}
else if (answer == 2)
{
System.out.println("That's right!");
correct = correct + 1;
}
System.out.println();
System.out.println("Q3) What is the 121/11+89?");
System.out.println(" "+ q3a1 +") 121");
System.out.println(" "+ q3a2 +") 100");
System.out.println(" "+ q3a3 +") 98");
System.out.print("Your answer: ");
answer = keyboard.nextInt();
if (answer == 1)
{
System.out.println("Incorrect!");
}
else if (answer == 2)
{
System.out.println("That's right!");
correct = correct + 1;
}
else if (answer == 3)
{
System.out.println("Incorrect!");
}
System.out.println();
System.out.println("Overall, you got " + correct + " out of "+ numberofquizes +" ");
System.out.println("Thanks for playing!");
}
}
Picture of the output