Assignemnt #39 and A Little Quiz
Code
/// Name: Mark Katz
/// Period: 6
/// Program Name: A Little Quiz
/// File Name: Quiz.java
/// Date Finished: 9/28/15
import java.util.Scanner;
public class Quiz
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int q1, q2, q3, response, count;
count = 0;
System.out.println( "Are you read for a quiz? (1= Yes 2= No)");
response = keyboard.nextInt();
if ( response == 1 )
{
System.out.println( "Ok, here it comes!");
}
else
{
System.out.println( "Well, youre gonna have to take it anyways!" );
}
System.out.println("");
System.out.println( " Q1: Is Nick a wierdo?" );
System.out.println( " 1) Yes" );
System.out.println( " 2) No" );
System.out.println( " 3) All of the above" );
System.out.println( "");
q1 = keyboard.nextInt();
if ( q1 == 1 )
{
System.out.println( "That's right!!!!" );
count++;
}
else
{
System.out.println( "Sorry, you're wrong!" );
}
System.out.println( "" );
System.out.println( " Q2: Where were Mark's parents born?" );
System.out.println( " 1) New York" );
System.out.println( " 2) Lithuania" );
System.out.println( " 3) Moscow" );
System.out.println( "" );
q2 = keyboard.nextInt();
if ( q2 == 2 )
{
System.out.println( "That's right!!!!!" );
count++;
}
else
{
System.out.println( "Sorry, you're wrong!" );
}
System.out.println( "" );
System.out.println( " Q3: What is 1+1??" );
System.out.println( " 1) 5000" );
System.out.println( " 2) 1.00001" );
System.out.println( " 3) 2" );
System.out.println( "" );
q3 = keyboard.nextInt();
if ( q3 == 3 )
{
System.out.println( "That's right!!!!" );
count++;
}
else
{
System.out.println( "Sorry, you're wrong!!" );
}
System.out.println( "You got " + count + " right!!!" );
}
}
Picture of the output