Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

  

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Starting Out With Java From Control Structures Through Data Structures

Authors: Tony Gaddis

6th Edition

0133957055, 978-0133957051

More Books

Students also viewed these Programming questions

Question

What does the term multitasking mean?

Answered: 1 week ago