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 input Game 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.
The first application you will complete simulates a fight with the mythical greek hydra. As legend goes, if you were to chop off the head of a hydra, two smaller heads would grow back in its place. In order for our fight to have an end, we will assume that once the size of the targeted head is small enough, no new heads will grow back in its place. The goal of this application is to determine the amount of work required to kill a hydra with a single head, when the size of the head is given as input. Final output would look like this The head bag is Bag[ 3 ]The head bag is Bag[ 2 2 ]The head bag is Bag[ 2 1 1 ]The head bag is Bag[ 2 1 ]The head bag is Bag[ 2 ]The head bag is Bag[ 1 1 ]The head bag is Bag[ 1 ]The head bag is Bag[ ]The number of chops required is 7Run the program again using 4 for the size of the initial head. The work done should be 15.Run the program again using 5 for the size of the initial head. You should get the computation ended early.Run the program again using 6…
When the player clicks on the “Start Game” button, in every 1 seconds, three random alphabets will be generated and flashing on the screen (e.g. A X W) at the position as shown above. The three alphabets must not repeat at the same time (i.e. can’t have repeating alphabets – e.g. A X A). After starting a game, you can’t change the chosen alphabet.
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