-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRps.java
53 lines (53 loc) · 1.7 KB
/
Rps.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
import java.util.Scanner;
public class Rps{
public static void main(String []args){
Scanner s = new Scanner (System.in);
System.out.println("rock, paper, scissors?");
String user = s.next().toLowerCase();
double comp = Math.random();
String a = "rock";
String b = "paper";
String c = "scissors";
if(!a.equals(user) && !b.equals(user) && !c.equals(user)){
System.out.println("Please check your spelling, the computer is very picky!");
}
else{
if (comp <= 0.33333){
System.out.println("Computer Choose: rock");
if (a.equals(user)){
System.out.println("Draw!");
}
if (b.equals(user)){
System.out.println("User Wins!");
}
if(c.equals(user)){
System.out.println("Computer Wins!");
}
}
else if (comp <= 0.66666 && comp > 0.33333){
System.out.println("Computer Choose: paper");
if (a.equals(user)){
System.out.println("Computer Wins!");
}
if (b.equals(user)){
System.out.println("Draw!");
}
if(c.equals(user)){
System.out.println("User Wins!");
}
}
else if (comp > 0.66666){
System.out.println("Computer Choose: scissors");
if (a.equals(user)){
System.out.println("User Wins!");
}
if (b.equals(user)){
System.out.println("Computer Wins!");
}
if(c.equals(user)){
System.out.println("Draw!");
}
}
}
}
}