-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRockPaperScissors.java
More file actions
48 lines (42 loc) · 1.62 KB
/
Copy pathRockPaperScissors.java
File metadata and controls
48 lines (42 loc) · 1.62 KB
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
import java.util.*;
import java.util.Random;
public class RockPaperScissors {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
Random number = new Random();
System.out.println("----- ROCK PAPER SCISSORS -----");
int comp_choice = number.nextInt(3);
System.out.println("1 = Rock \n2 = Paper \n3 = Scissors");
System.out.print("Enter number of your choice : ");
int user_choice = sc.nextInt();
System.out.println("Your choice = "+user_choice);
System.out.println("Computer Choice = "+comp_choice);
if(comp_choice == user_choice){
System.out.println("-- RESULT = GAME DRAW --");
}
else if(comp_choice == 1){
if(user_choice == 2){
System.out.println("-- RESULT = YOU WON --");
}
else if(user_choice == 3){
System.out.println("-- RESULT = YOU LOSE --");
}
}
else if(comp_choice == 2){
if(user_choice == 1){
System.out.println("-- RESULT = YOU LOSE --");
}
else if(user_choice == 3){
System.out.println("-- RESULT = YOU WON --");
}
}
else if(comp_choice == 3){
if(user_choice == 1){
System.out.println("-- RESULT = YOU WON --");
}
else if(user_choice == 2){
System.out.println("-- RESULT = YOU LOSE --");
}
}
}
}