-
Notifications
You must be signed in to change notification settings - Fork 92
/
ScissorRockPaper.java
57 lines (52 loc) · 1.34 KB
/
ScissorRockPaper.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package game;
import java.util.Random;
import java.util.Scanner;
public class Game {
public static void main(String[]args){
Scanner sc= new Scanner(System.in);
System.out.println("Enter '1' for scissor \nEnter'2' for rocks \nEnter '3' for paper");
for (int i=1; i<=3;i++) {
System.out.println("your turn Enter your number: ");
int num = sc.nextInt();
switch(num){
case 1:
System.out.println("you have Scissor ");
break;
case 2:
System.out.println("you have Rocks ");
break;
case 3:
System.out.println("you have Paper ");
break;
default:
System.out.println("please Enter number 1,2 & 3");
}
System.out.println();
System.out.println("Computer Turn");
Random r= new Random();
int low=1;
int high=3;
int result = r.nextInt(high - low)+low;
System.out.println(result);
switch(result){
case 1:
System.out.println("Computer have scissor ");
break;
case 2:
System.out.println("Computer have Rocks ");
break;
case 3:
System.out.println("Computer have Paper ");
break;
}
System.out.println();
if (result==1 && num==1 || result==2 && num==2 || result==3 && num==3){
System.out.println("match is draw");
}else if (result==2 && num==1 || result==3 && num==2 || result==1 && num==3) {
System.out.println("COMPUTER WIN");
}else{
System.out.println("USER WIN ");
}
}
}
}