package com.company;
import java.util.Random;
import java.util.Scanner;
public class CWH_Exercise02 {
public static void main(String[] args) {
System.out.println("Choose any one serial number");
System.out.println(" 0.scissor \n 1.Paper \n 2.Rock");
Scanner sc= new Scanner(System.in);
System.out.println("Enter a serial number");
int a= sc.nextInt();
switch (a){
case 0:
System.out.println("You selected scissor");
break;
case 1:
System.out.println("You selected Paper");
break;
case 2:
System.out.println("You selected Rock");
break;
default:
System.out.println("Abe pagal !! sahi number choose kr:)");
}
Random random=new Random();
int b= random.nextInt(2);
switch (b) {
case 0:
System.out.println("Rohan selected scissor");
break;
case 1:
System.out.println("Rohan selected Paper");
break;
case 2:
System.out.println("Rohan selected Rock");
break;
}
if (a == b) {
System.out.println("Game tied!!");
}
else {
if (a == 0) {
if (b == 1)
System.out.println("Tum jeete");
else if (b == 2)
System.out.println("Rohan jeeta");
}
if(a==1){
if (b == 0)
System.out.println("Rohan jeeta");
else if (b == 2)
System.out.println("tum jeete");
}
if(a==2){
if (b == 1)
System.out.println("Rohan jeeta");
else if (b == 0)
System.out.println("tum jeete");
}
}
}
}
Comments
Post a Comment