EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
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
Subject: Database management system Explain in easy way with write  handwritten note a. What is lossy decomposition? Check whether the following decompositions are lossy or lossless. (i) Let R=ABCD, R1 = AD, R2 = AB, R3 = BE, R4 = CDE, R5 = AE, F={ A->C, B- >C, C->D, DE->C, CE->A} (ii) R (XYZWQ), FD= {X->Z, Y->Z, Z->W, WQ->Z, ZQ-> X, R1 (XW), R2 (XY), R3 (YQ) , R4 (ZWQ), R5 (XQ) b. Eliminate redundant FDs from (i) F={X->Y, Y->X, Y->Z, Z->Y, X->Z, Z->X} (ii) F = {X->YZ, ZW->P, P->Z, W->XPQ, XYQ, YW, WQ ->YZ}
Please don't use AI
Don't use ai to answer I will report you answer
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