-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example14.java
84 lines (75 loc) · 2.73 KB
/
Example14.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import java.util.Scanner;
public class Example14 {
public static void main(String[] args)
{
Scanner enter = new Scanner(System.in);
char response;
int opt , option;
System.out.println("Are you ready for a Quiz?");
System.out.println("Enter Y for NO or N for No");
response = enter.next().charAt(0);
if(response == 'N')
{
System.out.println("Okay, Then you can leave and come another time!");
}
else if(response == 'Y')
{
System.out.println(" Okay, here it comes!\n");
System.out.println(" Q1) What is the capital of Alaska?\n");
System.out.println(" 1) Melbourne");
System.out.println(" 2) Anchorage");
System.out.println(" 3) Juneau");
opt = enter.nextInt();
if(opt == 1)
{
System.out.println("You are wrong!\n");
}
else if(opt == 2)
{
System.out.println("You are wrong!\n");
}
else if (opt == 3)
{
System.out.println("That's right!\n");
}
else
{
System.out.println(" ");
}
}
System.out.println(" Q1) Can you store the value cat in a variable of type int?");
System.out.println(" 1) Yes");
System.out.println(" 2) No\n");
option = enter.nextInt();
if( option == 1)
{
System.out.println("Sorry, cat is a string. ints can only store numbers\n");
}
else if(option == 2)
{
System.out.println("Wow, that's great! You are correct..\n");
}
else
{
System.out.println(" ");
}
System.out.println("What is the result of 9+6/3");
System.out.println(" 1) 5 ");
System.out.println(" 2) 11 ");
System.out.println(" 3) 15/3 \n");
opt = enter.nextInt();
if(opt == 1)
{
System.out.println("\nSorry, That's not correct!");
}
else if(opt == 2)
{
System.out.println("\nThat's correct!");
}
else if(opt == 3)
{
System.out.println("\nSorry, That's not correct!");
}
System.out.println("\nOverall, you got 2 out of 3 correct.\nThanks for playing");
}
}