Java Programming (MindTap Course List)
Java Programming (MindTap Course List)
8th Edition
ISBN: 9781285856919
Author: Joyce Farrell
Publisher: Cengage Learning
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 7, Problem 2GZ
Program Plan Intro

Enhancement of Rock Paper Scissors game

Program plan:

  • Import necessary packages.
  • Create a class “RockPaperScissors2”,
    • Define the “main()” method.
      • Declare a variable.
      • Declare and initialize variables.
      • Execute the following,
        • Create “Scanner” object.
        • Generate Random number.
        • Prompt the user to enter Rock or Paper or Scissor.
        • Increment the number of games.
        • Get the user input.
        • Take the first two characters of user input.
        • Convert it into upper case.
        • Execute switch statement,
        • If the random number is “3”.
          • Print a message.
          • Check if first two characters of user input is "PA", print a message, and increment the number of loses.
          • Else,
            • Check if first two characters of user input is "SC", print a message, and increment the number of ties.
          • Else,
            • Check if first two characters of user input is "RO", print a message, and increment the number of wins.
        • If the random number is “1”,
          • Print a message.
          • Check if first two characters of user input is "SC", print a message, and increment the number of loses.
          • Else,
            • Check if first two characters of user input is "RO", print a message, and increment the number of ties.
          • Else,
            • Check if first two characters of user input is "PA", print a message, and increment the number of wins.
        • If the random number is “2”,
          • Print a message.
          • Check if first two characters of user input is "SC", print a message, and increment the number of wins.
          • Else,
            • Check if first two characters of user input is "RO", print a message, and increment the number of loses.
          • Else,
            • Check if first two characters of user input is "PA", print a message, and increment the number of ties.
        • For a default case, print a message as “Invalid input.”.
      • Ask the user if they want to repeat or not,
      • Get the opinion.
    • Check the condition in exit “while” loop.
      • Print total number games.
      • Print total number wins.
      • Print total number loses.
      • Print total number ties.

Blurred answer
Students have asked these similar questions
Alert dont submit AI generated answer.
In physics, an object that is in motion is said to have kinetic energy. The following formula can be used to determine a moving object’s kinetic energy:KE = 1/2 mv2In the formula KE is the kinetic energy, m is the object’s mass in kilograms, and v is the object’s velocity in meters per second. Create an application that allows the user to enter an object’s mass and velocity and then displays the object’s kinetic energy. The application should have a method named KineticEnergy that accepts an object’s mass (in kilograms) and velocity (in meters per second) as arguments. The method should return the amount of kinetic energy that the object has.
Carpet Calculator The Westfield Carpet Company has asked you to write an application that calculates the price of carpeting for rectangular rooms. To calculate the price, you multiply the area of the floor (width times length) by the price per square foot of carpet. For example, the area of floor that is 12 feet long and 10 feet wide is 120 square feet. To cover that floor with carpet that costs $8 per square foot would cost $960. First, you should create a class named RoomDimension that has two fields: one for the length of the room and one for the width. The RoomDimension class should have a method that returns the area of the room. (The area of the room is the room’s length multiplied by the room’s width.) Next you should create a RoomCarpet class that has a RoomDimension object as a field. It should also have a field for the cost of the carpet per square foot. The RoomCarpet class should have a method that returns the total cost of the carpet. Figure 8-20 is a UML…
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
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Expressions in C++ | C++ tutorial for beginners; Author: Tutorial Mart;https://www.youtube.com/watch?v=XHbsZGpmRc8;License: Standard YouTube License, CC-BY
expression in python # python expressions; Author: Abhishek Tripathi;https://www.youtube.com/watch?v=Cc-kJGRjH6k;License: Standard Youtube License