Assignemnt #39 and Little Quiz
Code
/// Name: Raff Lisbona
/// Period: 6
/// Program Name: Little Quiz
/// File Name: LittleQuiz.java
/// Date Finished: 10/15/2015
import java.util.Scanner;
public class LittleQuiz
{
public static void main( String[] args )
{
String intro;
int answer1, answer2, answer3, total, count;
count = 0;
Scanner keyboard = new Scanner(System.in);
System.out.print( "Are you ready for a quiz? " );
intro = keyboard.next();
System.out.println( "Okay, here it comes!" );
System.out.println( " " );
System.out.println( "Q1) What is the capital of Alaska?" );
System.out.println( " \t 1) Melbourne" );
System.out.println( " \t 2) Anchorage" );
System.out.println( " \t 3) Juneau" );
System.out.println( " " );
System.out.print( "> " );
answer1 = keyboard.nextInt();
if ( answer1 == 3 )
{
System.out.println( "That's right!" );
count++;
}
else
{
System.out.println( "Sorry, the capital of Alaska is Juneau." );
}
System.out.println( " " );
System.out.println( "Q2) Can you store the value \"cat\" in a variable of type int?" );
System.out.println( "\t 1) yes" );
System.out.println( "\t 2) no" );
System.out.println( " " );
System.out.println( "> " );
answer2 = keyboard.nextInt();
if ( answer2 == 2 )
{
System.out.println( "That's right!" );
count++;
}
else
{
System.out.println( "Sorry, \"cat\" is a string. ints can only store numbers." );
}
System.out.println( " " );
System.out.println( "Q3) What is the result of 9+6/3?" );
System.out.println( "\t 1) 5" );
System.out.println( "\t 2) 11" );
System.out.println( "\t 3) 15/3" );
System.out.println( " " );
System.out.print( "> " );
answer3 = keyboard.nextInt();
System.out.println( " " );
if ( answer3 == 2 )
{
System.out.println( "That's correct!" );
count++;
}
else
{
System.out.println( "Sorry, the answer is 11. You'd know that if you weren't retarded." );
}
System.out.println( " " );
System.out.println( " " );
System.out.println( "Overall, you got " + count + " out of 3 correct." );
System.out.println( "Thanks for playing!" );
}
}
Picture of the output