Assignemnt #39 A little Quiz
Code
///Tyler Hart
///period 5
///A little Quiz
///Aquiz.java
///10/5/2015
import java.util.Scanner;
public class AQuiz
{
public static void main(String [] args)
{
Scanner keyboard = new Scanner(System.in);
int ans1, ans2, ans3, score;
score = 0;
System.out.println("QUIZ");
System.out.println("Q1) What is the capital of Alaska?");
System.out.println(" 1)Melbourne");
System.out.println(" 2)Anchorage");
System.out.println(" 3)Juneau");
ans1 = keyboard.nextInt();
if (ans1 == 3)
{
System.out.println("That's right!");
score = score+1;
}
else
{
System.out.println("That's not right. ;_;7");
}
System.out.println("Q2) Can you store the value \"cat\" in a variable of type int?");
System.out.println(" 1)yes");
System.out.println(" 2)no");
ans2 = keyboard.nextInt();
if (ans2 == 2)
{
System.out.println("That's right!");
score = score+1;
}
else
{
System.out.println("That's not right. ;_;7");
}
System.out.println("Q3) What is the result of 9+6/3?");
System.out.println(" 1)5");
System.out.println(" 2)11");
System.out.println(" 3)15/3");
ans3 = keyboard.nextInt();
if (ans3 == 2)
{
System.out.println("That's right!");
score = score+1;
}
else
{
System.out.println("That's not right. ;_;7");
}
System.out.println(" Your score is "+score);
}
}
Picture of the output