-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEleventh.java
119 lines (75 loc) · 2.48 KB
/
Eleventh.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import java.util.Random;
import java.util.Scanner;
public class Eleventh {
public static void main(String[] args) {
Random random=new Random(0);
Scanner sc = new Scanner(System.in);
System.out.println("Enter your Name");
String name=sc.nextLine();
System.out.println("DON'T ENTER NUMBER GREATER THAN 2 AS YOU WILL LOOSE THAT ROUND !!!");
System.out.println("Enter the number of rounds you want with the Computer");
int rounds=sc.nextInt();
int Ppoints=0;
int Cpoints=0;
int comp=random.nextInt(2);
for(int a =1;a<=rounds;a++){
System.out.println("Enter 0,1,2 for ROCK PAPER AND SICSSOR RESPECTIVELY");
int number=sc.nextInt();
System.out.println();
System.out.println("Round"+a);
if(number ==0){
System.out.println(name+"-Rock");
}
else if(number ==1){
System.out.println(name+"-Paper");
}
else if(number ==2){
System.out.println(name+"-Sicssor");
}
else{
System.out.println("Please enter a valid number");
}
if(comp ==0){
System.out.println("Computer-Rock");
}
else if(comp ==1){
System.out.println("Computer-Paper");
}
else if(comp ==2){
System.out.println("Computer-Sicssor");
}
if(number ==0 && comp==2){
System.out.println(name+"Won This Round");
Ppoints++;
}
else if(number ==1&& comp==0){
System.out.println(name+"Won This Round");
Ppoints++;
}
else if(number ==2&& comp==1){
System.out.println(name+ "Won This Round");
Ppoints++;
}
else if(number==comp){
System.out.println("It's a tie in This Round");
Ppoints++;
Cpoints++;
}
else{
System.out.println("Computer Won This Round");
Cpoints++;
}
System.out.println("Your Points--"+Ppoints);
System.out.println("Computer Points--"+Cpoints);
}
if(Ppoints>Cpoints){
System.out.println(name+"Won!!");
}
else if(Ppoints==Cpoints){
System.out.println("It's a Tie");
}
else{
System.out.println("Computer Won");
}
}
}