-
Notifications
You must be signed in to change notification settings - Fork 690
/
SmallAppofRandom.java
43 lines (34 loc) · 1.07 KB
/
SmallAppofRandom.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
import java.util.Random;
import java.util.Scanner;
class Guess
{
public static void main()
{
System.out.println("###############"+" "+"MATHEMATICS QUIZ"+" "+"###############");
int score,a,b,c;
score=0;
Random rg=new Random(System.currentTimeMillis());
Scanner d=new Scanner(System.in);
for(int x=1;x<=10;x++)
{
System.out.println("QUESTION"+" "+x);
a=rg.nextInt(39);
b=rg.nextInt(100);
System.out.println(a+"+"+b+"="+"__");
c=d.nextInt();
if(a+b==c)
{
score++;
System.out.println("Correct Answer");
System.out.println("Score:"+" "+score);
}
else
{
System.out.println("Incorrect Answer");
System.out.println("Score:"+" "+score);
}
}
System.out.println("Total Score"+"="+score);
System.out.println("Thanks for playing this game");
}
}