# Exercise 3.17 — Game: Scissor Rock Paper

Write a program that plays the popular scissor-rockpaper game. (A scissor can cut a paper, a rock can knock a scissor, and a paper can wrap a rock.) The program randomly generates a number 0, 1, or 2 representing scissor, rock, and paper. The program prompts the user to enter a number 0, 1, or 2 and displays a message indicating whether the user or the computer wins, loses, or draws.

```/**
*
* @Author: Aghatise Osazuwa
* Website: www.cscprogrammingtutorials.com
*/

import java.util.Scanner;

public class ComputeAndInterpretBMI {
public static void main (String [] args) {

int number, guess;

// Obtain the random number 0 or 1
number = (int) (Math.random() * 3);
// Prompt the user to enter a guess
Scanner input = new Scanner(System.in);

System.out.print("Guessing Game: Scissor, Rock, Paper."
+ "\nEnter 0 for Scissor, 1 for Rock or 2 for Paper: ");
guess = input.nextInt();

// Check the guess
if (number == 0 && guess == 0)
System.out.println("The computer is Scissors. You are Scissors too. It is a draw.");
if (number == 0 && guess == 1)
System.out.println("The computer is Scissors. You are Rock. You won.");
if (number == 0 && guess == 2)
System.out.println("The computer is Scissors. You are Paper. You lose.");
if (number == 1 && guess == 0)
System.out.println("The computer is Rock. You are Scissors. You lose.");
if (number == 1 && guess == 1)
System.out.println("The computer is Rock. You are Rock too. It is a draw.");
if (number == 1 && guess == 2)
System.out.println("The computer is Rock. You are Paper. You won.");
if (number == 2 && guess == 0)
System.out.println("The computer is Paper. You are Scissors. You won.");
if (number == 2 && guess == 1)
System.out.println("The computer is Paper. You are Rock. You lose.");
if (number == 2 && guess == 2)
System.out.println("The computer is Paper. You are Paper too. It is a draw.");
}
}
```

 Program sample run