Assignemnt #39: Interactive Quiz
Code
/// Name: Sean Harrison
/// Period: 7
/// Program name: Interactive Quiz
/// File Name: ALittleQuiz.java
/// Date Finished: 10/13/2015
import java.util.Scanner;
public class ALittleQuiz
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int Kaiser, Einstein, brain, total, score, a, b, c;
String response;
total = 3;
a = 0;
b = 0;
c = 0;
System.out.println( "Are you ready for a quiz? " );
response = keyboard.next();
System.out.println( "Okay, here it comes! " );
System.out.println( "Q1| Who was the founder on the second Reich? ");
System.out.println( "1| Adolf Hittler " );
System.out.println( "2| Hisenburg Weimar " );
System.out.println( "3| Kaiser Wilhelm II " );
Kaiser = keyboard.nextInt();
if ( Kaiser == 3 )
{
System.out.println( "Correct!" );
a = 1;
}
else if ( Kaiser != 3 )
{
System.out.println( "The founder of the 2nd Reich was Kaiser Wilhelm II " );
a = 0;
}
System.out.println( "Q2| Which Theory allowed for the development of nuclear technology? " );
System.out.println( "1| Law of Reletivity " );
System.out.println( "2| Boyle's Law " );
System.out.println( "3| Hawking Radiation " );
System.out.println( "4| Moore's Law ");
Einstein = keyboard.nextInt();
if ( Einstein == 1 )
{
System.out.println( "Correct!" );
b = a + 1;
}
else if ( Einstein != 1 )
{
System.out.println( "The Law of Reletivity allowed for the development of nuclear technology. ");
b = a + 0;
}
System.out.println( "Q3| Which area of the brain stores our memory? " );
System.out.println( "1| Central cortex " );
System.out.println( "2| Hippocampus " );
System.out.println( "3| Frontal Lobe " );
System.out.println( "4| Brain Stem " );
brain = keyboard.nextInt();
if ( brain == 2 )
{
System.out.println( "Correct!" );
c = b + 1;
}
else if ( brain != 2 )
{
System.out.println( "The hippocampus stores memory in our brain " );
c = b + 0;
}
System.out.println( "Overall, you got " + c + " out " + total + " correct. ");
}
}
Picture of the output