-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstonepaperscissors.java
43 lines (40 loc) · 1.41 KB
/
stonepaperscissors.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
import java.util.Scanner;
class SPS {
public static void main(String[] args) {
while (true) {
System.out.println("Welcome to the Game:");
Scanner sc = new Scanner(System.in);
System.out.println("Enter 1 for stone, 2 for paper or 3 for scissors ");
int x = sc.nextInt();
while(x<0||x>3){
System.out.println("Wrong Number. Enter Again: ");
x=sc.nextInt();
}
int y = (int) (Math.random() * 10);
while (y > 3 || y < 1) {
y = (int) (Math.random() * 10);
}
if(x==y){
System.out.println("It's A Draw");
}
else if(x==1 && y==2){
System.out.println("You chose Stone. CPU chose Paper. ");
System.out.println("You Lost");
}
else if(x==2&&y==1){
System.out.println("You chose Paper. CPU chose Stone");
System.out.println("You Won");
}
else if(x==1&&y==3){
System.out.println("You chose Stone. CPU chose Scissors");
System.out.println("You Won");
}
else if(x==2&&y==3){
System.out.println("You chose Paper. CPU chose scissors");
System.out.println("CPU won");
}
else if(x==)
}
}
}
}