Assignemnt #39 and a Little Quiz
Code
/// Name: Kyle Ivy
/// Period: 5
/// Program Name: Quiz
/// File Name: Quiz.java
/// Date Finished: 11/17/2015
import java.util.Scanner;
public class Quiz {
public static void main( String[] args ) {
Scanner keyboard = new Scanner(System.in);
int answer1 , answer2 , answer3;
int numberCorrect = 0;
System.out.println();
System.out.println( "Are you ready for a quiz? [hit y]" );
keyboard.next();
System.out.println( "Okay, here it comes!" );
System.out.println();
System.out.println( "Q1) Who is the current president? ");
System.out.println( " 1) Obama " );
System.out.println( " 2) Bush " );
System.out.println( " 3) Bin laden " );
System.out.println();
answer1 = keyboard.nextInt();
System.out.println();
if ( answer1 == 1)
{
numberCorrect += 1;
System.out.println( "That's right! ");
}
else
System.out.println( "Incorrect. " );
System.out.println();
System.out.println( "Q2) What did ancient Egyptians build? ");
System.out.println( " 1) Castles " );
System.out.println( " 2) Pyramids " );
System.out.println( " 3) Skyscrapers " );
System.out.println();
answer2 = keyboard.nextInt();
System.out.println();
if ( answer2 == 2)
{
numberCorrect += 1;
System.out.println( "That's right! ");
}
else
System.out.println( "Incorrect. They built Pyramids. " );
System.out.println();
System.out.println( "Q3) Bush did 9/11 ");
System.out.println( " 1) He definitely did not " );
System.out.println( " 2) Bush did 9/11 " );
System.out.println( " 3) He flew the plane " );
System.out.println();
answer2 = keyboard.nextInt();
System.out.println();
if ( answer2 == 2)
{
numberCorrect += 1;
System.out.println( "That's right! ");
}
else
System.out.println( "Incorrect, look at a textbook. " );
System.out.println();
System.out.println( "Overall, you got " + numberCorrect + " out of 3 correct. " );
System.out.println( "Thanks for playing!" );
}
}
prog39.PNG