-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab2_2.java
More file actions
50 lines (41 loc) · 1.88 KB
/
Lab2_2.java
File metadata and controls
50 lines (41 loc) · 1.88 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
49
50
import java.util.Scanner;
public class Lab2_2 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("scissor (0), rock (1), paper (2):");
int in = input.nextInt();
int rand = (int)(Math.random()*3);
String player =" ";
String com = " ";
switch(in)
{
case 0: player = "scissor"; break;
case 1: player = "rock"; break;
case 2: player = "paper"; break;
}
switch(rand)
{
case 0: com = "scissor"; break;
case 1: com = "rock"; break;
case 2: com = "paper"; break;
}
if(in == 0 )
{
if(rand == 0){System.out.println("The computer is "+com+". You are "+player+". It is a draw. ");};
if(rand == 1){System.out.println("The computer is "+com+". You are "+player+". You lose. ");};
if(rand == 2){System.out.println("The computer is "+com+". You are "+player+". You Win. ");};
}
else if(in ==1 )
{
if(rand == 0){System.out.println("The computer is "+com+". You are "+player+". You Win. ");};
if(rand == 1){System.out.println("The computer is "+com+". You are "+player+". It is a draw. ");};
if(rand == 2){System.out.println("The computer is "+com+". You are "+player+". You lose. ");};
}
else if(in ==2 )
{
if(rand == 0){System.out.println("The computer is "+com+". You are "+player+". You lose. ");};
if(rand == 1){System.out.println("The computer is "+com+". You are "+player+". You Win. ");};
if(rand == 2){System.out.println("The computer is "+com+". You are "+player+". It is a draw. ");};
}
}
}