-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathGame.java
More file actions
29 lines (23 loc) · 858 Bytes
/
Game.java
File metadata and controls
29 lines (23 loc) · 858 Bytes
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
import java.util.Scanner;
import java.util.Random;
class Game
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("enter 0 for rock , enter 1 for paper , enter 2 for scissors");
int userinput = sc.nextInt();
Random random= new Random();
int computerinput = random.nextInt(3);
if (userinput == computerinput)
{
System.out.println("DRAW");
}
else if (userinput==0 && computerinput==2 || userinput==1 && computerinput==0 ||
userinput==2 && computerinput==1)
{
System.out.println("you win");
}
else {
System.out.println("you lost");
}
}}