Skip to content

Commit 78c8e67

Browse files
Random.java
A program who tells the importance of Random function in java coding language.
1 parent 484a814 commit 78c8e67

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

SmallAppofRandom.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import java.util.Random;
2+
import java.util.Scanner;
3+
class Guess
4+
{
5+
public static void main()
6+
{
7+
System.out.println("###############"+" "+"MATHEMATICS QUIZ"+" "+"###############");
8+
int score,a,b,c;
9+
score=0;
10+
Random rg=new Random(System.currentTimeMillis());
11+
Scanner d=new Scanner(System.in);
12+
for(int x=1;x<=10;x++)
13+
{
14+
System.out.println("QUESTION"+" "+x);
15+
a=rg.nextInt(39);
16+
b=rg.nextInt(100);
17+
System.out.println(a+"+"+b+"="+"__");
18+
c=d.nextInt();
19+
20+
if(a+b==c)
21+
{
22+
score++;
23+
System.out.println("Correct Answer");
24+
System.out.println("Score:"+" "+score);
25+
26+
}
27+
else
28+
{
29+
System.out.println("Incorrect Answer");
30+
System.out.println("Score:"+" "+score);
31+
}
32+
33+
}
34+
35+
System.out.println("Total Score"+"="+score);
36+
System.out.println("Thanks for playing this game");
37+
}
38+
}
39+
40+
41+
42+
43+

0 commit comments

Comments
 (0)