Assignemnt #39, A Little Quiz
Code
/// Name: Ales Pinder
/// Period: 5
/// Program Name: Space Boxing
/// File Name: prog38.java
/// Date Complete: 11/05/15
import java.util.Scanner;
public class prog39
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int first, second, third, overall;
overall = 0;
System.out.println( "Q1. What is the square root of -1?\n\t1. -1\n\t2. i\n\t3. 1" );
first = keyboard.nextInt();
if ( first == 2 )
{
System.out.println( "Correct" );
overall = overall + 1;
}
else
{
System.out.println( "Incorrect" );
}
System.out.println( "Q2. Is it true that Abe Linclon was the 17th presedent.\n\t1. Yes\n\t2. No" );
second = keyboard.nextInt();
if ( second == 2 )
{
System.out.println( "Correct" );
overall = overall + 1;
}
else
{
System.out.println( "Incorrect" );
}
System.out.println( "Q3. Solve 10x+20=30.\n\t1. x=3\n\t2. x=2\n\t3. x=1" );
third = keyboard.nextInt();
if ( third == 3 )
{
System.out.println( "Correct" );
overall = overall + 1;
}
else
{
System.out.println( "Incorrect" );
}
System.out.println( "Overall you got " + overall + " out of 3 correct!\nThanks for playing!" );
}
}
Picture of the output