Repository navigation
Expand file tree
/
Copy pathmoduleTwo.java
More file actions
37 lines (35 loc) · 1.43 KB
/
Copy pathmoduleTwo.java
File metadata and controls
37 lines (35 loc) · 1.43 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
import java.util.Scanner;
public class moduleTwo {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Does player one choose rock, paper, or scissors? ");
String playerOne = input.next();
System.out.print("Does player two choose rock, paper, or scissors? ");
String playerTwo = input.next();
if (playerOne.equals("rock")){
if (playerTwo.equals("scissors")) {
System.out.println("Player one wins");
} else if (playerTwo.equals("paper")) {
System.out.println("Player two wins");
} else {
System.out.println("Draw try again");
}
} else if (playerOne.equals("paper")){
if (playerTwo.equals("rock")) {
System.out.println("Player one wins");
} else if (playerTwo.equals("scissors")) {
System.out.println("Player two wins");
} else {
System.out.println("Draw try again");
}
} else { //if playerOne chooses scissors
if (playerTwo.equals("rock")) {
System.out.println("Player two wins");
} else if (playerTwo.equals("paper")) {
System.out.println("Player one wins");
} else {
System.out.println("Draw try again");
}
}
}
}