Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Statement: You are tasked to implement a C++ program that simulates a basketball shooting game for a local high school. The game supports 2

image text in transcribedimage text in transcribed

Problem Statement: You are tasked to implement a C++ program that simulates a basketball shooting game for a local high school. The game supports 2 players, with each player attempting to score as many points as possible by making shots from five fixed shooting positions. At each shooting position, there is a rack of five basketballs. Out of the five balls, the first four are regular balls, are worth one point each. The fifth ball, often nicknamed the "money ball", is worth two points. The "money ball" can only be shot after the four regular balls are shot. Of those five positions, the player can choose a position to have a rack consisting only of "money balls", which are all worth two points. This position is called "money-ball rack". The goal of this game is to score as many points as possible. Player 1 needs to finish shooting from all five positions before the next player shoots. The player with the highest score at the end of the game is the winner. After the game is completed, the players will have the option to play again or quit. The program should run until being asked to quit. Implementation Requirements: 1. Before each player shooting, prompt them to choose the "money-ball rack" position. The program should re-prompt until a valid input is given. 2. For both players, assuming there is always a 50% chance of successfully making the shot, no matter it is for the regular balls or the money balls. (hint: use rand() function). 3. For each player, you must use an array to keep track of the shooting result for displaying later and calculating the final score. ( Note: it is okay to use multiple arrays to store the shooting result for one player.) 4. The shooting result of each player should be displayed using the following notation: - X for missed shots - O for made shots worth 1 point - M for made shots worth 2 points (the "money ball") 5. For each player, the program needs to display the scores for each rack, and the total score. 6. After both players have completed their shooting, declare the winner (or a tie game). 7. Prompt the players to enter whether they want to play again or quit the game, until a valid input a given. 8. Your program must handle all types of errors and be able to recover from them. Example Output: (User inputs are highlighted) Note: You don't have to follow the example output exactly, but you need to display all required fields and they must be readable. Welcome to the 3pt shooting contest! Player 1: Where do you want to put your money-ball rack? Enter 1-5: 4 Rack 2: 0 o 0XXx 3pts Rack 4: M M X M M I 8 pts Rack 5: XXX2pts Total: 22 pts Player 2: Where do you want to put your money-ball rack? Enter 1-5: 0 That's not a valid input. Where do you want to put your money-ball rack? Enter 1-5: 5 Rack 1: X X X X X I 0 pts Rack 2: OXXXX1pts Rack 4: O X OX X 2 pts Rack 5: M M M M M I 10 pts Total: 19 pts Player 1 is the winner!! Do you want to play again? (1-yes, 0-no): no Sorry, that's not a valid input. Do you want to play again? (1-yes, 0-no): 0 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxxviii Special Issue On Database And Expert Systems Applications Lncs 11250

Authors: Abdelkader Hameurlain ,Roland Wagner ,Sven Hartmann ,Hui Ma

1st Edition

3662583836, 978-3662583838

More Books

Students also viewed these Databases questions

Question

What is paper chromatography?

Answered: 1 week ago

Question

Explain the cost of capital.

Answered: 1 week ago