Assignment # 39 and Quiz
Code
/// Name: Tommy Oyuntseren
/// Period: 7
/// Program Name: Quiz
/// File Name: Quiz.java
/// Date: 11/2/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 Mongolia?");
System.out.println(" 1) Ulaanbaatar");
System.out.println(" 2) Darkhan");
System.out.println(" 3) Erdenet");
System.out.println();
System.out.print("> ");Q1 = keyboard.nextInt();
if ( Q1 == 1){
System.out.println();
System.out.println(" That's right! " );
System.out.println();
}
else if ( Q1 == 2){
result += 1;
System.out.println();
System.out.println(" wrong " );
System.out.println();
}
else if ( Q1 == 3){
result += 1;
System.out.println();
System.out.println(" no no no!! " );
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 60 + 9?");
System.out.println(" 1) 19");
System.out.println(" 2) 21");
System.out.println(" 3) 69");
System.out.println();
System.out.print("> ");Q3 = keyboard.nextInt();
if (Q3 == 1) {
System.out.println();
System.out.println(" That's no!!!! " );
System.out.println();
}
else if (Q3 == 2){
System.out.println();
System.out.println(" GO STUDY! " );
System.out.println();
}
else if (Q3 == 3) {
result += 1;
System.out.println();
System.out.println(" That's CORRECT!!!! " );
System.out.println();
}
System.out.println("Overall, you got " + result + " out of 3!!!!");
System.out.println("Thank you for playing!!");
System.out.println();
}
}
Picture of the output