Mr. Truncale - Robert E. Lee High School
  • Home
  • Digital Media
    • HTML
  • Video Game Design
  • Comp. Programming I
  • Comp. Programming II
  • AP Computer Science
  • 3D Printing
  • Teacher Resources
  • Contact Me

Java - If RoShamBo


Create a new class called RoShamBo.  Type what you see below.  Finish the game by putting in the appropriate if statements.  There should be 9 in total (one is written for you).
// This program will play Paper Rock Scissors with the user.

// VARIABLES

Scanner keyboard = new Scanner(System.in);
int computerChoice;
int playerChoice;

// GENERATE COMPUTERS CHOICE
computerChoice = (int) (Math.random() * 3) + 1; // random number 1-3

// GET PLAYERS CHOICE
System.out.println("===+ PLAY ROSHAMBO | Paper Rock Scissors +===\n");
System.out.print("Enter a number 1-3 : 1 PAPER | 2 ROCK | 3 SCISSORS : ");
playerChoice = keyboard.nextInt();

// SEE WHO WINS
// These are the 3 messages that should be printed out:
// System.out.println("You Win! Computer chose ...");
// System.out.println("You Lose! Computer chose ...");
// System.out.println("You Tie! Computer also chose ...");


if (playerChoice == 1 && computerChoice == 1) {
   System.out.println("You Tie! Computer also chose PAPER.");
}

// TODO: Finish the if statements for the game.  Game should have 9 in total.
TURN IN

Powered by Create your own unique website with customizable templates.