Assignemnt #39
Code
/// Name: Connor Siri
/// Period: 7
/// Program Name: Quiz
/// File Name: Quiz.java
/// Date Finished: 10/6/2015
import java.util.Scanner;
class Quiz{
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String quiz;
int Q1, Q2, Q3;
System.out.print("Are you ready for a quiz? ");
quiz = keyboard.next();
System.out.println("Okay, here it comes!");
System.out.println("Q1) What is your name?");
System.out.println(" 1) King Auther of Camolot");
System.out.println(" 2) George");
System.out.println(" 3) Harry");
System.out.print("> ");
Q1 = keyboard.nextInt();
if ( Q1 == 1 )
{
System.out.println("That's right!");
}
else
{
System.out.println("Sorry, That's wrong");
}
System.out.println("Q2) What is your quest");
System.out.println(" 1) To help my friend");
System.out.println(" 2) To find the Holy Grail");
System.out.println(" 3) To find my hat");
System.out.print(">");
Q2 = keyboard.nextInt();
if ( Q2 == 2 )
{
System.out.println("That's right!");
}
else
{
System.out.println("Sorry, that's wrong");
}
System.out.println("Q3) What is the average velocity of a unburdened swollow");
System.out.println(" 1) 10 m/s");
System.out.println(" 2) It depends, is the swollow African or European");
System.out.println(" 3) It depends on the gender and age");
System.out.print(">");
Q3 = keyboard.nextInt();
if ( Q3 == 2 )
{
System.out.println("That's right!");
}
else
{
System.out.println("Sorry, that's wrong");
}
if ( Q1 == 1 && Q2 == 2 && Q3 == 2 )
{
System.out.println("Overall, you got 3 out of 3 correct.");
}
else if ( Q1 == 1 && Q2 == 2)
{
System.out.println("Overall, you got 2 out of 3 correct.");
}
else if ( Q1 == 1 && Q3 == 2 )
{
System.out.println("Overall, you got 2 out of 3 correct.");
}
else if ( Q2 == 2 &&Q3 == 2 )
{
System.out.println("Overall, you got 2 out of 3 correct.");
}
else if ( Q1 == 1 )
{
System.out.println("Overall, you got 1 out of 3 correct.");
}
else if ( Q2 == 2 )
{
System.out.println("Overall, you got 1 out of 3 correct.");
}
else if ( Q3 == 2 )
{
System.out.println("Overall, you got 1 out of 3 correct.");
}
else
{
System.out.println("Overall, you got 0 out of 3 correct.");
}
}
}
Picture of the output