Convert given python code to Java Code def RSP(): guess = while (True): guess = input(Enter
Fantastic news! We've Found the answer you've been seeking!
Question:
Convert given python code to Java Code
Transcribed Image Text:
def RSP(): guess = "" while (True): guess = input("Enter (r)ock, (s) cissors, or (p)aper: ") if (guess not in ["r", "s", "p"]): print("Only 'r', 's', or 'p' are valid inputs! Please try again.") else: break rand = random() if (rand < 1/3): comp = "r" elif (rand < 2/3): comp= "s" else: comp = "p" if (guess == comp): print("It is a tie!") elif ((guess == 'r') and (comp=== 'p')) or \ ((guess == 'p') and (comp== 's')) or \ ((guess 's') and (comp == 'r')): print("Sorry, you lost as I had", comp) print("Congrats, you won as I had", comp) RSP() else: -- def RSP(): guess = "" while (True): guess = input("Enter (r)ock, (s) cissors, or (p)aper: ") if (guess not in ["r", "s", "p"]): print("Only 'r', 's', or 'p' are valid inputs! Please try again.") else: break rand = random() if (rand < 1/3): comp = "r" elif (rand < 2/3): comp= "s" else: comp = "p" if (guess == comp): print("It is a tie!") elif ((guess == 'r') and (comp=== 'p')) or \ ((guess == 'p') and (comp== 's')) or \ ((guess 's') and (comp == 'r')): print("Sorry, you lost as I had", comp) print("Congrats, you won as I had", comp) RSP() else: --
Expert Answer:
Related Book For
Data Structures and Algorithms in Python
ISBN: 978-1118290279
1st edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
Posted Date:
Students also viewed these programming questions
-
Consider the following information: Suppliers' payment period 40 days Receivables' collection period 40 days Finished goods...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
5. Decrypt the ciphertext message "UXDL" that was encrypted with the function f(p) = (5p+ 3) mod 26. ABCDEFGHIJKLM 2 3 4 5 6 7 8 9 10 11 12 0 1 2 NO PQRSTUVWXYZ 13 14 15 16 17 18 19 20 21 22 23 24 25
-
What tensions may arise if a shareholder-centric model is imposed on a stakeholder-focused society?
-
Salmon fishing in Alaska is a seasonal business; May through September is the best time to bait salmon and halibut. Toland Fisheries, a small commercial fishery, recorded its highest ever catch last...
-
What interests, if any, do you believe the statethat is, the government (on all levels)should have in promoting marriage? Why
-
What are the three steps of the planning phase of the strategic marketing process? Answer: The three steps of the planning phase of the strategic marketing process are: (1) Conducting a situation...
-
CAF Company sells office equipment and supplies to many organizations in the city and surrounding area on contract terms of 2/10, n/30. In the past, over 75% of the credit customers have taken...
-
please help me. and make sure the answer is corect and make it clearly please. help me and thank you. this is all i have for the question. this is all the amount i have in hand . sorry and please...
-
The following information pertains to the City of Williamson for 2024, its first year of legal existence. For convenience, assume that all transactions are for the general fund, which has three...
-
nclude correctly labeled diagrams, if useful or required, in explaining your answers. A correctly labeled diagram must have all axes and curves clearly labeled and must show directional changes. If...
-
What is the logical ending point of a sequential game that starts at position (2,8) with player 1 moving first? Show your work. Player 1 Strategy B Strategy A Strategy A Player 2 Strategy B (3,4)...
-
Problem A-6 Income and Retained Earnings Statements Peanut Corporation is a private corporation using ASPE. At December 31, 2017, an analysis of the accounts and discussions with company officials...
-
8.5 Area Between Curves (dy) Calculus-Calculator Allowed Mastery Check #2 Name: Date: Period: For 1-2, find the area of the region bounded by the following curves. Show the integral set up with...
-
Your company has a travel policy that reimburses employees for the "ordinary and necessary" costs of business travel. Employees often mix a business trip with pleasure by either extending the time at...
-
Simulation A: 1 Diameter 600 mm 2 Focal Length 1800 mm 3 F/D Ratio 3 4 Eyepieces 30 m 5 Barlow? N 6 Celestial Sights M42 - M31 - M51 Simulation B: 1 Diameter 150 mm 2 Focal Length 1800 mm 3 F/D Ratio...
-
What is the best option from a strictly financial standpoint? For simplicity, assume all salaries are paid in full at the end of each year. Greg was discussing his analysis with a friend, who...
-
A supermarket chain is interested in exploring the relationship between the sales of its store-brand canned vegetables (y), the amount spent on promotion of the vegetables in local newspapers (x1)...
-
Write a Python class that extends the Progression class so that each value in the progression is the absolute value of the difference between the previous two values. You should include a constructor...
-
Our DynamicArray class, as given in Code Fragment 5.3, does not support use of negative indices with _ _getitem_ _. Update that method to better match the semantics of a Python list. Code Fragment...
-
An old MST method, called Bar uvkas algorithm, works as follows on a graph G having n vertices and m edges with distinct weights: Let T be a subgraph of G initially containing just the vertices in V....
-
10.7. As a regional managing director of Finco, a U.S.- based investment company, your mandate is to scour the Midwest in search of promising investment opportunities and to recommend one project to...
-
10.3. Respond to parts a through d. a. What are the incremental cash flows associated with Small Corp.s undertaking project X? Are these inflows or outflows, costs or revenue? b. What is the PV of...
-
10.5. Let Bt price per $100 of face value of a zerocoupon bond maturing at year t. Then, if B1 $94.00, B2 $88.20, B3 $81.50, B4 $76.00, and B5 $73.00, implying that the term structure of...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App