MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / main

Method main

Programs/RockPaperScissor.java:6–29  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

4public class Rockpaperscissor {
5
6 public static void main(String[] args) {
7 Scanner sc = new Scanner(System.in);
8 System.out.println("Choose Any One:\n1. Rock \n2. Paper \n3. Scissor");
9 int user = sc.nextInt();
10 if (user > 3 || user < 1) {
11 System.out.println("Plz type valid input");
12 return;
13 }
14
15 Random random = new Random();
16 int computer = random.nextInt(1, 4);
17 System.out.println("YOU CHOOSE: "+user);
18 System.out.println("Computer Choose: "+computer);
19
20 if (user == 1 && computer == 1 || user == 2 && computer == 2 || user == 3 && computer == 3) {
21 System.out.println("Match Tie");
22 } else if (user == 1 && computer == 3 || user == 2 && computer == 1 || user == 3 && computer == 2) {
23 System.out.println("Hurray! YOU WIN");
24 } else {
25 System.out.println("Better luck next Time: Computer WIN");
26 }
27
28
29 }
30}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected