EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Videos

Question
Book Icon
Chapter 5, Problem 5GZ
Program Plan Intro

Rock Paper Scissors game

Program plan:

  • Import necessary package.
  • Create a class “RockPaperScissors”,
    • Define the method “main()”,
    • Declare and initialize the necessary variables.
    • Generate the random value for the computer.
    • Assign the integer value returned from the method “parseInt()”.
    • Check whether the user value is “1”,
      • If it is true set the string as “rock”.
    • Otherwise, check whether the user value is “2”,
      • If it is true set the string as “paper”.
    • Otherwise,
      • Set the string as “scissors”.
    • Check whether the computer value is “1”,
      • If it is true set the string as “rock”.
    • Otherwise, check whether the computer value is “2”,
      • If it is true set the string as “paper”.
    • Otherwise,
      • Set the string as “scissors”.
    • Check whether the user value is “1”,
      • Check whether the computer value is “1”,
        • If it is true, set the string as “tie”.
          • Otherwise, check whether the computer value is “2”,
            • If it is true, set the string as “computer”.
          • Otherwise, set the string as “you”.
    • Check whether the user value is “2”,
      • Check whether the computer value is “2”,
        • If it is true, set the string as “tie”.
          • Otherwise, check whether the computer value is “3”,
            • If it is true, set the string as “computer”.
          • Otherwise, set the string as “you”.
    • Otherwise, check whether the computer value is “3”,
      • If it is true, set the string as “tie”.
    • Otherwise, check whether the computer value is “1”,
      • If it is true, set the string as “computer”.
    • Otherwise, set the string as “you”.
    • Display the output message in dialog box.

Blurred answer
Students have asked these similar questions
In the game Rock Paper Scissors, two players simultaneously choose one of three options: rock, paper, or scissors. If both players choose the same option, then the result is a tie. However, if they choose differently, the winner is determined as follows:Rock beats scissors, because a rock can break a pair of scissors.Scissors beats paper, because scissors can cut paper.Paper beats rock, because a piece of paper can cover a rock.Create a game in which the computer randomly chooses rock, paper, or scissors.Let the user enter a number 1, 2, or 3, each representing one of the three choices.Then, determine the winner.Program should validate all user inputGame should ask the user to play again and continue if yes and stop if no.Once the user stops playing, program should print the total number of wins.
In the game Rock Paper Scissors, two players simultaneously choose one of three options: rock, paper, or scissors. If both players choose the same option, then the result is a tie. However, if they choose differently, the winner is determined as follows: • Rock beats scissors, because a rock can break a pair of scissors. • Scissors beats paper, because scissors can cut paper. • Paper beats rock, because a piece of paper can cover a rock. Create a game in which the computer randomly chooses rock, paper, or scissors. Let the user enter a number 1, 2, or 3, each representing one of the three choices. Then, determine the winner. Save the application as RockPaperScissors.java
JavaRock Paper Scissors Lizard SpockRock Paper Scissors Lizard Spock is a variation of the common game Rock Paper Scissors that isoften used to pass time (or sometimes to make decisions.) The rules of the game are outlinedbelow:• Scissors cuts Paper• Paper covers Rock• Rock crushes Lizard• Lizard poisons Spock• Spock smashes Scissors• Scissors decapitates Lizard• Lizard eats Paper• Paper disproves Spock• Spock vaporizes Rock• Rock crushes ScissorsWrite a program that simulates the game of Rock Paper Scissors Lizard Spock!• The user should be able to enter Strings for each of their choices (e.g. “Rock” for Rock,“Paper” for Paper etc…).o The code should also ensure that the user only enters the strings Rock, Paper orScissors (and they should be able to enter upper or lower case versions).§ Use a while loop with the equalsIgnoreCase method from the String classfor best results!• The computer should generate a random value 0, 1, 2, 3, or 4 that would be translatedinto Rock, Paper,…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY