Assignment #39 A little quiz
Code
///Name: Ian Grant
///Period:5
///Project Name: A little quiz
///File Name:quiz.java
///10/21/15
import java.util.Scanner;
public class quiz
{
public static void main(String[] args)
{
int ans,score=0;
Scanner stuff=new Scanner(System.in);
//Question 0
System.out.println("Are you ready for a quiz? ");
System.out.println("\t 1. YES ");
System.out.println("\t 2. NO ");
System.out.println("\t 3. Unsure ");
ans=stuff.nextInt();
if (ans==1)
{
System.out.println("Correct!");
score++;
}
else if (ans==2)
{
System.out.println("Incorrect!");
}
else if (ans==3)
{
System.out.println("It's ok I won't judge you? Maybe.");
}
else
{
System.out.println("That's not ok. I will judge you for that!");
}
//Question 1
System.out.println();
System.out.println("What is funnier than 24?");
System.out.println("\t 1. 26");
System.out.println("\t 2. 25");
System.out.println("\t 3. 42");
ans=stuff.nextInt();
if (ans==1)
{
System.out.println("Incorrect! Obviously 25 is funnier than 24.");
}
else if (ans==2)
{
System.out.println("Correct!!!");
score++;
}
else if (ans==3)
{
System.out.println("Incorrect! Obviously 25 is funnier than 24.");
}
else
{
System.out.println("ERROR?!");
}
//Question 2
System.out.println();
System.out.println("Is the cake a lie?");
System.out.println("\t 1. Yes");
System.out.println("\t 2. Possibly, Unsure what a cake is.");
System.out.println("\t 3. No, definatly not the cake has to be real!");
ans=stuff.nextInt();
if (ans==1)
{
System.out.println("Correct!");
score++;
}
else if (ans==2)
{
System.out.println("Incorrect! A cake is made of flour, eggs, sugar, and milk. It is sweet and delicious!");
}
else if (ans==3)
{
System.out.println("Please go to the reeducation building, test subject #15437325684.");
}
else
{
System.out.println("ERROR?!");
}
//Question 3
System.out.println();
System.out.println("What is 2+2?");
System.out.println("\t 1. 5");
System.out.println("\t 2. What is a two and could you explain addition?");
System.out.println("\t 3. 4");
ans=stuff.nextInt();
if (ans==1)
{
System.out.println("Run! Get out of 1984");
}
else if (ans==2)
{
System.out.println("Please go back to school Timmy.");
}
else if (ans==3)
{
System.out.println("Correct!!.");
score++;
}
else
{
System.out.println("ERROR?!");
}
System.out.println("Overall you got "+score+" out of 3 correct.");
}
}
Output