Assignemnt #39 A Little Quiz
Code
///Name: Prooz Fereydouni
///Period: 7
///Project Name: A Little Quiz
///File Name: AlQ.java
///Date: 10/24/2015
import java.util.Scanner;
public class ALQ
{
public static void main( String []args)
{
Scanner keyboard = new Scanner(System.in);
int answer, totalCorrect=0 ;
System.out.println( "Hello, Are you ready to take a random survey of knowledge?");
System.out.println("What is the capital of Ukraine?");
System.out.println("1. Budapest");
System.out.println("2. Tehran");
System.out.println("3. Kiev");
System.out.println("4. Moscow");
System.out.println("");
System.out.println("Please enter your answer.");
answer = keyboard.nextInt();
if(answer == 3)
{
System.out.println("You are correct!");
totalCorrect += 1;
}
else
{
System.out.println("The answer was incorrect. The correct answer was 3. Kiev.");
}
System.out.println("");
System.out.println("Who was the third president of the United States?");
System.out.println("1. Thomas Jefferson");
System.out.println("2. George Washington");
System.out.println("3. Andrew Jackson");
System.out.println("4. Barack Obama");
System.out.println("Please enter your answer.");
answer = keyboard.nextInt();
System.out.println("");
if(answer == 1)
{
System.out.println("You are correct!");
totalCorrect += 1;
}
else
{
System.out.println("The answer was incorrect. The correct answer was 1. Thomas Jefferson.");
}
System.out.println("");
System.out.println("What is the answer to (4/9)^(3/2)");
System.out.println("1. 4/9");
System.out.println("2. 8/27");
System.out.println("3. 2/3");
System.out.println("4. I can't do math");
System.out.println("Please enter your answer.");
answer = keyboard.nextInt();
System.out.println("");
if(answer == 2)
{
System.out.println("You are correct!");
totalCorrect += 1;
}
else
{
System.out.println("The answer was incorrect. The correct answer was 2. 8/27.");
}
System.out.println("");
System.out.println("Well done, you got " + totalCorrect + " out of 3 correct.");
}
}
Picture of the output