Assignemnt #4 and A Little Quiz
Code
/// Name: Tristan Chung
/// Period: 5
/// Program Name: Little Quiz
/// File Name: LittleQuiz.java
/// Date Finished: 10/29/2015
import java.util.Scanner;
public class LittleQuiz
{
public static void main( String[] args )
{
int q1, q2, q3, score;
String ready;
score = 0;
Scanner keyboard = new Scanner(System.in);
System.out.print("Ready for a quiz? ");
ready = keyboard.next();
System.out.println("Okay, here it comes!");
System.out.println(" ");
System.out.println("Q1) What is Guam?");
System.out.println(" 1. A city in the Philippines");
System.out.println(" 2. A pacific island U.S territory");
System.out.println(" 3. A fruity beverage");
System.out.println(" ");
System.out.print("> ");
q1 = keyboard.nextInt();
System.out.println(" ");
if (q1 == 2)
{
score = score + 1;
System.out.println("That's correct!");
}
else
{
System.out.print("No, its a part of the U.S. duhhhhh");
}
System.out.println(" ");
System.out.println("Q2) Who is the god of fire in Greek mythology?");
System.out.println(" 1. Zeus");
System.out.println(" 2. Venus");
System.out.println(" 3. Hephaestus");
System.out.println(" 4. Vulcan");
System.out.println(" ");
System.out.print("> ");
q2 = keyboard.nextInt();
if (q2 == 3)
{
score = score + 1;
System.out.println("That's correct!");
}
else if (q2 == 4)
{
System.out.println("No, Vulcan is the Roman god of fire");
}
else
{
System.out.println("No, its Hephaestus obviously");
}
System.out.println(" ");
System.out.println("Q3) How tall is the Burj Khalifa in Bali?");
System.out.println(" 1. 2,700 ft");
System.out.println(" 2. 2,000 ft");
System.out.println(" 3. 1.800 ft");
System.out.println(" 4. 1,900 ft");
System.out.println(" ");
System.out.print("> ");
q3 = keyboard.nextInt();
if (q3 == 1)
{
score = score + 1;
System.out.println("That's correct! isn't that gigantic!?");
}
else if (q3 == 2)
{
System.out.println("Nope that's the height of the Shanghai Tower");
}
else if (q3 == 3 )
{
System.out.println("No that's the height of the World Trade Center");
}
else if (q3 == 4 )
{
System.out.println("No that's the height of the Makkah Royal Clock Tower Hotel");
}
System.out.println(" ");
System.out.println(" ");
if ( score == 0 )
{
System.out.println("Overall, you got 0 out 3 correct.");
System.out.println("Thanks for playing!");
}
else if ( score == 1 )
{
System.out.println("Overall, you got 1 out 3 correct.");
System.out.println("Thanks for playing!");
}
else if ( score == 2 )
{
System.out.println("Overall, you got 2 out 3 correct.");
System.out.println("Thanks for playing!");
}
else if ( score == 3 )
{
System.out.println("Overall, you got 3 out 3 correct.");
System.out.println("Thanks for playing!");
}
}
}
Picture of the output