Assignemnt #39 and A Little Quiz
Code
///Name: Daniel Tiffany-Appleton
///Period: 7
///Program Name: A Little Quiz
///File Name: ALittleQuiz
///Date Finished: 10/9/15
import java.util.Scanner;
public class ALittleQuiz
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String readiness;
int answerQOne, answerQTwo, answerQThree;
boolean Yes, No;
System.out.print( "Are you ready for a quiz? Yes or No. " );
readiness = keyboard.next();
Yes = readiness.equals("Yes");
No = readiness.equals("No");
if ( Yes )
{
System.out.println( "Great, Here we go!" );
}
else if ( No )
{
System.out.println( "Well you are doing it anyway." );
}
System.out.println( "Q1) What is Brian, the Messiah." );
System.out.println( "\t 1) A normal guy \n\t 2) A very naughty boy \n\t 3) There was no Brian" );
answerQOne = keyboard.nextInt();
if ( answerQOne == 2 )
{
System.out.println( "That is correct!" );
}
else
{
System.out.println( "That is wrong; Try harder" );
}
System.out.println( "Q2) Should you also look on the bright side of life?" );
System.out.println( "\t 1) True \n\t 2) False" );
answerQTwo = keyboard.nextInt();
if ( answerQTwo == 1 )
{
System.out.println( "That is correct!" );
}
else
{
System.out.println( "That is wrong; Try harder" );
}
System.out.println( "Q3) Who is Bigus Dickus's wife?" );
System.out.println( "\t 1) Mammaria Gigantia \n\t 2) Incontinentia Buttocks \n\t 3) Facia Unpleasantia" );
answerQThree = keyboard.nextInt();
if ( answerQThree == 2 )
{
System.out.println( "That is correct!" );
}
else
{
System.out.println( "That is wrong; Try harder" );
}
if ( answerQOne == 2 && answerQTwo == 1 && answerQThree == 2 )
{
System.out.println( "You got 3 out of 3 correct" );
}
else if ( answerQTwo == 1 || answerQThree == 2 && answerQOne == 2 || answerQOne == 2)
{
System.out.println( "You got 2 out of 3 correct" );
}
else if ( answerQTwo == 1 || answerQThree == 2 || answerQOne == 2 )
{
System.out.println( "You got 1 out of 3 correct" );
}
else
{
System.out.println( "You got 0 out of 3 correct" );
}
}
}
Picture of the output