-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstone_paper_scissors.java
68 lines (64 loc) · 2.23 KB
/
stone_paper_scissors.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
58
59
60
61
62
63
64
65
66
67
68
package com.company;
import java.util.Scanner;
import java.util.Random;
public class stone_paper_scissors {
public static void main(String[] args) {
System.out.println("Stone paper scissors Game");
try (Scanner sc = new Scanner(System.in)) {
Random rand=new Random();
int i=1;
Byte sin=0;
Byte scin=0;
while (i<=5) {
System.out.println("Score of you "+sin);
System.out.println("Score of computer "+scin);
System.out.println("The "+i+"st match");
System.out.println("Enter your choice\n"+"0-Stone\n"+"1-Paper\n"+"2-Scissors");
Byte in=sc.nextByte();
System.out.println("Your Entered choice is"+in);
int cin=rand.nextInt(3);
System.out.println("Computer's choice is"+cin);
if(in == cin)
{
System.out.println("Its a Draw");
}
else if(in==0 && cin==2)
{
System.out.println("You won");
sin++;
}
else if(in==2 && cin==1)
{
System.out.println("You won");
sin++;
}
else if(in==1 && cin==0)
{
System.out.println("You won");
sin++;
}
else
{
System.out.println("Oops!Computer won");
scin++;
}
System.out.println("Score of you "+sin);
System.out.println("Score of computer "+scin);
i++;
System.out.println(" ");
}
if (sin > scin) {
System.out.println("You won the match");
}
else if(sin == scin){
System.out.println("Its a tie match");
}
else
{
System.out.println("Computer won the match");
}
}
// int rand1=rand.nextInt(3);
// System.out.println(rand1);
}
}