Assignemnt #39: A little Quiz
Code
/// Name: Cassie
/// Period: 6
/// Program Name: A Little Quiz
/// File Name: lilquiz.java
/// Date Finished: 11/3/2015
import java.util.Scanner;
public class lilquiz
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String answer;
int q1, q2, q3, points=0;
System.out.print( "Are you ready for a quiz? " );
answer = keyboard.next();
System.out.println( "Okay, here it comes!" );
System.out.println( "Q1) True or False: Kit Kats are the best candy ever invented" );
System.out.println( " 1) False, they're are a sad excuse for a candy bar" );
System.out.println( " 2) True, but Kit Kat Minis are better" );
System.out.print( "Answer: " );
q1 = keyboard.nextInt();
if ( q1 == 1 )
{
System.out.println( "You're wrong... Next question" );
System.out.println( "- 1 points" );
}
if ( q1 == 2 )
{
System.out.println( "You're correct" );
System.out.println( "+ 1 points" );
points += 1;
}
System.out.println( "How many pure breeds of puppies are in existence?" );
System.out.println( " 1) 83641364" );
System.out.println( " 2) 300" );
System.out.print( "Answer: " );
q2 = keyboard.nextInt();
if ( q2 == 1 )
{
System.out.println( "You're incorrect" );
System.out.println( "- 1 points" );
}
if ( q2 == 2 )
{
System.out.println( "You're correct" );
System.out.println( "+ 1 points" );
}
System.out.println( "True or False" );
System.out.println( "Puppies are the best thing that this world has created" );
System.out.println( " 1) True" );
System.out.println( " 2) False" );
System.out.print( "Answer: " );
q3 = keyboard.nextInt();
if ( q3 == 1 );
{
System.out.println( "You're correct" );
System.out.println( "+ 1 points" );
points += 1;
}
if ( q3 == 2 );
{
System.out.println( "You suck" );
System.out.println( "- 1 points" );
}
System.out.println( "Overall, you got " + points + " out of 3 correct" );
System.out.println( "Thanks for playing" );
}
}
Picture of the output