Assignemnt #39 - Quiz
Code
/// Name: Caelan Dorstad
/// Period: 6
/// Program Name: Quiz
/// File Name: Quiz.java
/// Date Finished: 10/1/2015
import java.util.Scanner;
public class Quiz{
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
int Q1, Q2, Q3, result;
String respond;
System.out.print("Are you ready for a quiz? ");
respond = keyboard.next();
System.out.println("Okay, here it comes!");
System.out.println();
result = 0;
System.out.println("Q1) What is the capital of South Korea?");
System.out.println(" 1) Gangnam");
System.out.println(" 2) Seoul");
System.out.println(" 3) pyongyang");
System.out.println();
System.out.print("> ");Q1 = keyboard.nextInt();
if ( Q1 == 1){
System.out.println();
System.out.println(" Wrong! " );
System.out.println();
}
else if ( Q1 == 2){
result += 1;
System.out.println();
System.out.println(" That's right!!! " );
System.out.println();
}
else if ( Q1 == 3){
System.out.println();
System.out.println(" Wrong!!! " );
System.out.println();
}
System.out.println("Q2) Can you store the value \"1,000,000\" in a variable of type String?");
System.out.println(" 1) Yes");
System.out.println(" 2) No");
System.out.println();
System.out.print("> ");Q2 = keyboard.nextInt();
if ( Q2 == 1){
System.out.println();
System.out.println(" Wrong!!! " );
System.out.println();
}
else if( Q2 == 2){
result += 1;
System.out.println();
System.out.println(" That's CORRECT!!!! " );
System.out.println();
}
System.out.println("Q3) What's 9 + 10?");
System.out.println(" 1) 19");
System.out.println(" 2) 21");
System.out.println(" 3) 910");
System.out.println();
System.out.print("> ");Q3 = keyboard.nextInt();
if (Q3 == 1) {
result += 1;
System.out.println();
System.out.println(" That's CORRECT!!!! " );
System.out.println();
}
else if (Q3 == 2){
System.out.println();
System.out.println(" That's ALSO CORRECT!!!! BUT NO CREDIT! " );
System.out.println();
}
else if (Q3 == 3) {
System.out.println();
System.out.println(" WRONG!!!! " );
System.out.println();
}
System.out.println("Overall, you got " + result + " out of 3!!!!");
System.out.println("Thank you for palying!!");
System.out.println();
}
}
Picture of the output