Java Programming (MindTap Course List)
Java Programming (MindTap Course List)
9th Edition
ISBN: 9781337397070
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
JAVA Guess-the-Number Game Write an application that plays “guess the number” as follows: Your application chooses the number to be guessed by selecting an integer at random in the range 1–1000. The application then displays  the following in a label: I have a number between 1 and 1000. Can you guess my number? Please enter your first guess. A JTextField should be used to input the guess. }  As each guess is input, the background color should change to either red or blue. Red indicates that the user is getting “warmer,” and blue, “colder.” A JLabel should display either "Too High" or "Too Low" to help the user zero in. When the user gets the correct answer, "Correct!" should be displayed, and the JTextField used for input should be changed to be uneditable. A JButton should be provided to allow the user to play the game again. When the JButton is clicked, a new random number should be generated and the input JTextField changed to be editable.
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.
Write a tkinter application that asks the user to create their own pizza. First, they should enter their name. Then, allow them to pick one of three crusts (thin, regular, deep dish), one of three sauces (Regular, BBQ, Alfredo), and any number of 3 toppings (Pepperoni, Olives, Mushroom). They should also pick if they want a small, medium, or large pizza. When the submit button is clicked, calculate the total cost ($10 base price, $0.50 for each topping, and $1.50 for each increase in size larger than small).  Once the total is calculated, display a messagebox that thanks the user (by name) for their order and prints out the total cost.
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,
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