You will write a program that simulates a two-player game of Morra. Your program must do...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You will write a program that simulates a two-player game of Morra. Your program must do the following for each round of play until the game is over: • At the beginning of each round, print out the round number. The first round is round 1. • Read from the console the number of fingers shown by player 1, the number of fingers shown by player 2, player 1's guess at the sum, and player 2's guess at the sum. • Print to the console whether any players made a correct guess, and if so, that player's new point total. If neither player guessed correctly, print a message indicating this. Note that BOTH players might guess correctly, in which case they both earn a point! Once the game is over, print the final outcome of the game. There are a few possibilities: • Print Player X wins! where X is either 1 or 2 depending on which player won. • If, however, the winning player won by a score of 3 to 0, instead print Player X wins a glorious victory!, again where X is either 1 or 2 as appropriate. • It is possible that the game is a tie. For example, if the score is 2 to 2, and both players guess correctly in the next round, both players will have three points when the game ends. In such a case, instead of printing either of the above messages, print It's a tie!. Sample Runs A couple of sample runs demonstrating program behaviour are given in the appendix at the end of this document (this is not because they are unimportant, but because they are rather long to insert here). Tips and Hints (a) Remember: you don't have to generate player moves randomly. You are reading them from the con- sole each round. Think of your program as the referee - it asks for the players moves each round using console input, then reports on the outcome of each round using console output, and finally prints the outcome of the game. (b) Your program only has to play one full game. To referee another game, run the program again! (c) You may assume that the user enters only valid data. That is, you do not have to actually check whether player moves are between 0 and 5 and that their guesses are between 0 and 10. Just assume that You will write a program that simulates a two-player game of Morra. Your program must do the following for each round of play until the game is over: • At the beginning of each round, print out the round number. The first round is round 1. • Read from the console the number of fingers shown by player 1, the number of fingers shown by player 2, player 1's guess at the sum, and player 2's guess at the sum. • Print to the console whether any players made a correct guess, and if so, that player's new point total. If neither player guessed correctly, print a message indicating this. Note that BOTH players might guess correctly, in which case they both earn a point! Once the game is over, print the final outcome of the game. There are a few possibilities: • Print Player X wins! where X is either 1 or 2 depending on which player won. • If, however, the winning player won by a score of 3 to 0, instead print Player X wins a glorious victory!, again where X is either 1 or 2 as appropriate. • It is possible that the game is a tie. For example, if the score is 2 to 2, and both players guess correctly in the next round, both players will have three points when the game ends. In such a case, instead of printing either of the above messages, print It's a tie!. Sample Runs A couple of sample runs demonstrating program behaviour are given in the appendix at the end of this document (this is not because they are unimportant, but because they are rather long to insert here). Tips and Hints (a) Remember: you don't have to generate player moves randomly. You are reading them from the con- sole each round. Think of your program as the referee - it asks for the players moves each round using console input, then reports on the outcome of each round using console output, and finally prints the outcome of the game. (b) Your program only has to play one full game. To referee another game, run the program again! (c) You may assume that the user enters only valid data. That is, you do not have to actually check whether player moves are between 0 and 5 and that their guesses are between 0 and 10. Just assume that
Expert Answer:
Answer rating: 100% (QA)
Program roundnum stores the round number roundnum0 p1points stores the points of player 1 p1points0 p2points stores the points of player 2 p2points0 this loop is executed as long as p1points and p1poi... View the full answer
Related Book For
Starting Out With Java From Control Structures Through Data Structures
ISBN: 9780133957051
6th Edition
Authors: Tony Gaddis
Posted Date:
Students also viewed these programming questions
-
"How might incorporating personalized learning paths for employees impact their skill acquisition and overall performance within an organization's training and development program?"
-
In this project, we will write a program that controls a quiz show, much like the many popular TV shows. The program will read in a group of questions and their multiple choice answers, storing them...
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
A SQL With respect to database transaction, the ACID concepts should apply! ACID is an acronym for atomicity, consistency, isolation and durability. Please define each of these terms in your own...
-
A satellite will travel indefinitely in a circular orbit around a planet if the normal component of the acceleration of the satellite is equal to g(R/r)2 , where g is the acceleration of gravity at...
-
Write a function that will scale down just a part of the picture. Make someones head look smaller.
-
Listed below are a number of research questions and hypotheses from actual published articles. For each hypothesis, identify the independent and dependent variable. a. The use of color in a Yellow...
-
Fifteen years ago, roop industries sold $400 million of convertible bonds. the bonds had a 40-year maturity, a 5.75% coupon rate, and paid interest annually. they were sold at their $1,000 par value,...
-
Greenwood Company manufactures two products-15,000 units of Product Y and 7,000 units of Product Z. The company uses a plantwide overhead rate based on direct labor-hours. It is considering...
-
Arbortech, a designer, manufacturer, and marketer of PC cards for computers, printers, telecommunications equipment, and equipment diagnostic systems, was the darling of Wall Street during Year 6....
-
Use the empirical rule to solve the problem. The amount of Jen's monthly phone bill is normally distributed with a mean of $150 and a standard deviation of $11. What percentage of her phone bills are...
-
Determine the life-time value of an acquired customer (V). Show your work. Assuming the customer will renew policy for 5 years and our average premium for this demographic group is $950 per year and...
-
NSW REAL ESTATE Explain the relevance of budgets and financial reporting in Property Management including who a Property Manager would need to report such activities to on some occasions.
-
The IIA's Code of Ethics applies to Recipients of IIA certifications only. Institute members and certified internal auditors only. Institute members but not candidates for certifications. Anyone...
-
BlueInk Roadways Corporation operates throughout the United States. The following data (in millions) were adapted from recent financial statements of BlueInk. Year 2 Year 1 Net sales $15,504 $9,685...
-
Beginning Capital Balance- 25600 Net Income or Loss for the period- 20300 Additional Investments or Withdrawals by the owner(s)- 4500 Drawing made by the owner(s) during the period.- CALCULATE
-
Arrange the following steps of the regulation of the trp operonin order of occurrence. _The trp repressor protein binds to the operator _levels of tryptophan rise and more is required -Tryptophan...
-
Is it ethical to provide safety training in English to immigrant workers who speak little English, in order to reduce costs?
-
Last month Joe purchased some stock in Acme Software, Inc. Here are the details of the purchase: The number of shares that Joe purchased was 1,000. When Joe purchased the stock, he paid $32.87 per...
-
What does the term multitasking mean?
-
Using the following chart, write an if-else-if statement that assigns .10, .15, or .20 to commission, depending on the value in sales. Sales Up to $10,000 $10,000 to $15,000 Over $15,000 Commission...
-
What would the QA/QC planning grid (see Figure 12. 6) look like for a project you have been involved in? Data from Figure 12. 6 Table 12.6 QA/QC planning grid, with examples Quality assurance...
-
Why is the definition of quality critical to the success and acceptance of a project?
-
What is the purpose of the Quality Management Plan?
Study smarter with the SolutionInn App