EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
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.
- Define the “main()” method.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents 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
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
- Solve the 3 questions using MATLAB code & show your work on how pretty pleasearrow_forwardSubject: DBMS Explain in easy way and do not use chatgpt A database is being constructed to keep track of the teams and games of a sports league. A team has a number of players, not all of whom participate in each game. It is desired to keep track of the players participating in each game for each team, the positions they played in that game, and the result of the game. Design an ER schema diagram for this application, stating any assumptions you make. Choose your favorite sport (e.g., soccer, baseball, football).arrow_forwardhelp with this pleasearrow_forward
- For the control system plot root Locus and find the D gain of stability? by Matlab Ris Kp (5+3) S+5 (s+1) +CUST s(S+2) (565+18) 5-1 5²+35+4arrow_forwardCIS 115 Introduction to C++ May I please have a written review expressing my gratitude for a tutor that has given me guidance throughout the computer programming course? Thank you so much!arrow_forwardMath 130 Introduction to Java programming May I please have a written review expressing my gratitude for a tutor that has given my guidance throughout my computer programming course? Thank youarrow_forward
- Please help me translate the java code to jack codearrow_forwardTranslate the following VM commands to Assembly instructions: □ push constant 1 □ push constant 5arrow_forwardSuppose the state of the argument and local memory segments are as follows: argument local stack 0 0 9 sp-> 256 1 257 1 14 2 258 259 Now consider the following VM code: 1 push constant 2 pop local @ 3 push constant 15 4 pop local 1 5 push local 1 6 push argument 1 7 gt 8 pop local 2 9 push local 0 10 push argument 0 11 add 12 pop local 0 13 push local 1 14 push local 1 15 push constant 1 16 sub 17 add 18 pop local 1 What will be the value of local 1 after the VM code has executed?arrow_forward
- Suppose the state of the RAM is as follows and the adjacent assembly code will execute: RAM 0 3 1 2 2 0 فيا 3 6 456 5 1 4 1234567 $1 A = M A = M A = M D = M @4 M = D What will be the value of the RAM[4] following the assembly code execution?arrow_forwardPlease help me answer this , the context is for the Nand2Tetris Hack Assembly VM Emulatorarrow_forwardhelp filling this out pleasearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
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