-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.java
36 lines (31 loc) · 1.24 KB
/
Main.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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("_____________________________");
System.out.println(" Welcome To Trampling");
System.out.println(" Gambling Centre");
System.out.println("");
System.out.println(" Enter a Number Between 0-10");
System.out.println(" If You Correct, You win!");
System.out.println(" If You Wrong, You Lose!");
System.out.println("_____________________________");
System.out.println("");
int gamble;
Scanner sc = new Scanner(System.in);
int number = 0;
do {
gamble = (int) (Math.random() * 10);
System.out.println("Enter Your Number (0-10): ");
number = sc.nextInt();
if (number > 10 || number < 0) {
System.err.println("Error");
} else if (number == gamble) {
System.out.println("You Won!");
System.out.println("The Answer is " + gamble);
} else if (number != gamble) {
System.out.println("You Lose!");
System.out.println("The Answer is " + gamble);
}
} while (gamble != number);
}
}