Rock-Paper-Scissors
Implement Rock-Paper-Scissors such that the user can play the computer in a best-of series! The user inputs the number of rounds which should be positive and odd. This is a free form assignment but structure your code similar to the test cases provided. USING MATLAB ONLY!!!
Program Inputs
• How many rounds would you like to play (odd rounds only)?:
XXX
– XXX should be positive and odd. Restart the game if the input is not positive or odd.
Program Outputs
• XXX wins this round
– Replace XXX with either User or Computer depending on who wins the round • Game Over!
– After the Game is over display the times User and Computer won after the total number of rounds. Finally display who wins the entire game.
Sample Outputs:
Test Case 1:
Welcome to Rock-Paper-Scissors! Play if you dare! How many rounds would you like to play (odd rounds only)? 3 You choose to do best out of 3 rounds ********************************************************* Round 1 ********************************************************* Rock (0)... Paper (1)... Scissors (2)... Shoot: 1 The computer chooses Rock and you picked Paper User wins this round! *********************************************************
********************************************************* Round 2 ********************************************************* Rock (0)...
Paper (1)... Scissors (2)... Shoot: 2 The computer chooses Rock and you picked Scissors Computer wins this round! *********************************************************
********************************************************* Round 3 ********************************************************* Rock (0)...
Paper (1)... Scissors (2)... Shoot: 1 The computer chooses Scissors and you picked Paper Computer wins this round! *********************************************************
********************************************************* Game over! User won 1 out of 3 rounds Computer won 2 out of 3 rounds
Computer wins! Did you expect anything else? *********************************************************
Test Case 2:
Welcome to Rock-Paper-Scissors! Play if you dare! How many rounds would you like to play (odd rounds only)? 3 You choose to do best out of 3 rounds ********************************************************* Round 1 ********************************************************* Rock (0)... Paper (1)... Scissors (2)... Shoot: 5 How dare you cheat at rock paper scissors! You lose this round! You muggle! *********************************************************
********************************************************* Round 2 ********************************************************* Rock (0)...
Paper (1)... Scissors (2)... Shoot: 7 How dare you cheat at rock paper scissors! You lose this round! You muggle! *********************************************************
********************************************************* Game over! User won 0 out of 3 rounds Computer won 2 out of 3 rounds
Computer wins! Did you expect anything else? *********************************************************
Test Case 3:
Welcome to Rock-Paper-Scissors! Play if you dare! How many rounds would you like to play (odd rounds only)? 1 You choose to do best out of 1 rounds ********************************************************* Round 1 ********************************************************* Rock (0)... Paper (1)... Scissors (2)... Shoot: 5 How dare you cheat at rock paper scissors!
You lose this round! You muggle! *********************************************************
********************************************************* Game over! User won 0 out of 1 rounds Computer won 1 out of 1 rounds
Computer wins! Did you expect anything else? *********************************************************
Test Case 4:
Welcome to Rock-Paper-Scissors! Play if you dare! How many rounds would you like to play (odd rounds only)? 2 2 is not a valid number of rounds... Try again! *********************************************************
How many rounds would you like to play (odd rounds only)? 1 You choose to do best out of 1 rounds ********************************************************* Round 1 ********************************************************* Rock (0)...
Paper (1)... Scissors (2)... Shoot: 1 The computer chooses Paper and you picked Paper This round is a tie! Replaying this round... *********************************************************
********************************************************* Round 1 ********************************************************* Rock (0)...
Paper (1)... Scissors (2)... Shoot: 1 The computer chooses Scissors and you picked Paper Computer wins this round! *********************************************************
********************************************************* Game over! User won 0 out of 1 rounds Computer won 1 out of 1 rounds
Computer wins! Did you expect anything else? *********************************************************
In: Computer Science
Write a C++ program that prompts the user (or “Player 1”) to input an integer value between 1 and 3 (where 1=paper, 2=scissor, and 3=rock). This input should be passed into a string function called player_RPS(), and returns a string value indicating the selection of paper, scissors, or rock (as mentioned above). Next, the returned string value, along with a generated input from the computer, should be passed into a void function called RPS_comparison(), and determines whether the user’s input or the computer’s generated input is the winner or if both inputs result in a tie.
This program should play this game ten consecutive times and call a function named winner_tally_to_file()to append the winner (either PLAYER1-WINS!!!, COMPUTER-WINS!!!, or TIE!!!) of each match to a text file called rps.txt. After the 10thmatch, this program should call a function named official_tally_from_file() to read the stored data from the rps.txt file back into the program, place this data into a 2x5 two-dimensional array, and print this data to screen after the array is traversed. While this data is being stored in the array, the program should tally the number wins for Player 1, Computer, and TIE, respectively, and output the entity with the most wins:
Please Code in C++
In: Computer Science
Question 3 [10 marks] Anyone who bets money in a casino is
classified as a winner if he or she wins more than he or she loses.
Casino operators in Atlantic City, New Jersey, believe that the
proportion of all players who go home a winner is 0.46. Suppose 75
Atlantic City gamblers are selected at random.
a. [3 marks] Find the sampling distribution of the proportion of
gamblers who go home winners.
b. [2 marks] Find the probability that the sample proportion is
less than 0.40.
c. [2 marks] Find the probability that the sample proportion is
more than 0.45.
d. [3 marks] Find a symmetric interval about the mean (p=0.46) such
that the probability that the sample proportion is in this interval
is 0.99
In: Statistics and Probability
1. One kilogram of liquid water at 75°C is heated in a frictionless piston at a constant pressure of 5 bar. A total of 2750.7 kJ of heat is added. For each answer, just put the number in the blank without units, and round to the nearest whole number (no decimals). And remember that "water" can mean liquid or vapor. a) What is the final temperature of the water in °C b) What is the final volume of the water in liters c) How much work was done in kJ d) What is the total change in internal energy (∆U) of the water in kJ.
In: Other
It is required to lift a skip whose load total is 1kN. Two
simple lifting jacks are available both having an effort piston
diameter of 10mm and a load piston diameter of 70mm and the load is
to be distributed equally between the two.
Calculate:
a) the force ratio and movement ratio of each jack.
b) the pressure within the hydraulic fluid.
In: Mechanical Engineering
n ideal gas is enclosed in a cylinder with a movable piston on top of it. The piston has a mass of 8,000 g and an area of 5.00 cm2 and is free to slide up and down, keeping the pressure of the gas constant. (a) How much work is done on the gas as the temperature of 0.180 mol of the gas is raised from 30.0°C to 325°C?
In: Physics
1. Florence, who weighs 560 N, stands on a bathroom scale in an elevator. What will she see the scale read when the elevator is accelerating upward at 5 m/s2?(g = 9.8 m/s2) Newtons
2.You swing a 3.41 kg bucket of water in a vertical circle of radius 0.900 m. At the top of the circle the speed of the bucket is 3.25 m/s. Find the tension in the rope tied to the bucket at the top of the circle
In: Physics
Need to make Java code as following:
Create a dice playing threading program to do the following:
1. Start a thread for a process to simulate a computer rolling a die 1000 times.
2. Start another thread for a process to simulate a user rolling a die 1000 times.
3. Keep track of rolls for user and computer in an array(s).
4. Display on screen when the computer thread starts, the rolls, and when the computer thread ends.
5. Display on screen when the user thread starts, the rolls, and when the user thread ends.
6. Once the rolls are completed for both computer and user, use the array(s) to count number of computer wins, number of user wins, and ties. Each element of one array is compared to each element in the other array by index. So computerRoll[0] is compared to userRoll[0], etc.
In: Computer Science
You have been asked to design an elevator system.
The functions of an elevator includes moving up and down, open and close doors, and pick up passengers.
The elevator is supposed to be used in a building having floors numbered from 1 to MaxFloor, where the first floor is the lobby.
There are car call buttons in the car corresponding to each floor.
For every floor except for the top floor and the lobby, there are two hall call buttons for the passengers to call for going up and down.
There is only one down hall call button at the top floor and one up hall call button in the lobby. When the car stops at a floor, the doors are opened and the car lantern indicating the current direction the car is going is illuminated so that the passengers can get to know the current moving direction of the car.
The car moves fast between floors, but it should be able to slow down early enough to stop at a desired floor. In order to certificate system safety, emergency brake will be triggered and the car will be forced to stop under any unsafe conditions.
Follow the process documented above to design the Elevator System.
Questions :
1. Specify the requirements
2. Design a solution
3. Implement the solution with java
4. Test the solution
In: Computer Science