forked from thakurRashmi/Begineer_Friendly_Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIf-else.java
More file actions
25 lines (21 loc) · 899 Bytes
/
If-else.java
File metadata and controls
25 lines (21 loc) · 899 Bytes
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
import java.util.Random;
import java.util.Scanner;
public class Stone {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int bound;
System.out.println(" enter for Rock=0;Paper=1;sec=2");
int userInput = sc.nextInt();
Random random = new Random();
int computerInput = random.nextInt(bound = 2);
if (userInput == computerInput) {
System.out.println("draw");}
else if (userInput == 0 && computerInput == 2 || userInput == 1 && computerInput == 0 || userInput == 1 && computerInput == 0|| userInput == 2 && computerInput == 1) {
System.out.println("YOU WIN!");
}
else {
System.out.println("COMPUTER WIN!");
}
System.out.println("computer choice:"+computerInput);
}
}