Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

General Description: Write an application that allows the user to enter, view, search and sort statistics on a team of basketball players. The program should

General Description:

Write an application that allows the user to enter, view, search and sort statistics on a team of basketball players. The program should start by reading data from a file called bballin.txt, and should end by writing data to a file called bballout.txt.

A Statistic (stat) in the program consists of two numbers:

- number of points made

- number of points attempted.

A percentage is calculated with the formula (100*made)/attempted, rounded off. When the points attempted is zero, the percentage is zero.

Percentages are printed in the format mm/aa (nnn%) where mm is the points made, aa is the points attempted, and nnn is the percentage [note: always length 12]. Examples:

0/0( 0%) 12/12 (100%) 5/10 ( 50%)

A Player has the following data kept:

- name

- jersey number

- number of games played (max 40) [note: this number will be the same for all players] and three lists of stats, one stat per game per list:

- 3-point field goals

- 2-point field goals

- free throws

Other data can be calculated from these stats:

- A stat of the overall 3-pointers (sum of 3-pointers made/attempted in all games).

- A stat of the overall 2-pointers (sum of 2-pointers made/attempted in all games).

- A stat of the overall free throws (sum of free throws made/attempted in all games).

- A list of total points scored, one for each game, calculated as:

3-pointers-made * 3 + 2-pointers-made * 2 + free-throws-made

Printing a report for a player should look like this example. The name is as is read from the file. The jersey number is in square brackets. image text in transcribed

A Team consists of:

- A list of Players

- The number of players (max 10)

- The number of games (max 15)

A user should be able to perform the following operations (one method each) on a team:

Print the Team Report:

Print the stat report for all players with a blank line between each player. Use the report format shown above. The program should pause after printing the last player.

Add a game to each player on the Team:

The user is asked to enter the stats for a new game for every player in the list. For each player, it should:

- Display the players name and jersey number in square

brackets.

- Ask the user to enter the shots made and attempted for

- 3-pointers

- 2-pointers

- Free throws -

If the program already has the maximum number of games allowed, it should print a message and not add a new game.

image text in transcribed

Display a player by jersey number:

The program should ask the player to enter the jersey number of the player to find. When a player with the entered number is not found, it should print Player not found.

When the player is found, it should print the players stat report as usual.

image text in transcribed

Remove a player from the Team:

The program should ask the player to enter the jersey number of the player to remove. When a player with the number entered is found, the program removes the player from the list and prints a message Player name [jersey] removed. When the player is not found, the program prints Player not found.

Sort Team by Name:

The program sorts its internal list of players by name (names as is...no need to parse the name for first/last/etc.). It simply prints a message Players sorted by name on the screen.

Sort Team by Jersey:

The program sorts its internal list of players by jersey number. It simply prints a message Players sorted by jersey on the screen.

2

Read Team data:

On startup, the program should read the current team data from a file named bballin.txt. The format of the file is as follows:

image text in transcribed

The first line contains the number of players and number of games.

- For each player:

o The first line contains the jersey number

and name. The name may contain

spaces. o For each game, there is one line of six

numbers: 3-pointers made 3-pointers attempted 2-pointers made 2-pointers attempted Free throws made Free throws attempted.

Write Team Data:

When the program ends, it should write the current data to a text file named bballout.txt in the exact same format at the input file.

Overall Operation:

The program should start by printing a logo with your name and section.

It should then display a menu of options and allow the user to an option. The program performs the selected option. When an invalid option is chosen, the program prints an error message. This repeats until the user enters the exit option

image text in transcribed

Specifications:

You will note that the main() uses a class called team, and that it invokes methods inside an object of this class. Therefore, you should:

- Add team.h header file to the project. Code the class interface there.

- Add team.cpp source file to the project. Code the class

implementation there.

- Use the exact spelling of the class and methods as used in the main()

There should be a set() method and a get() method for each member. o Each set() should validate the given arguments when needed (ex: points made

attempted). When arguments are invalid, do not change the members and print an

error message. o set()s may be combined where it makes sense. Ex: for a stat, set(made,attempted) is

good. o Exception: if you need an internal use only member for a class, set() and get() are not

required.

- Do not use file streams (ifstream, ofstream) in any method besides the read() and write() methods of class team. Use methods of any sub-objects to set() and get() data from them.

Here is the txt

4 3 15 Smith, Sam 0 0 2 3 3 5 2 3 5 6 2 2 3 7 0 5 1 8 22 Fender, Freddy 0 0 4 4 4 6 4 5 12 24 4 5 3 4 18 30 4 4 33 Ant, Adam 2 5 0 2 6 7 0 3 8 10 2 6 2 6 16 18 1 5 45 Carrot, Carl 5 6 18 22 0 0 3 4 19 35 1 2 10 11 22 30 2 3 

Please attach the entire file here.

Thank you in advance.

Carrot, Carl [45] Game 3-Point FGS 2-Point FGs Free Throws Total 5/ 6 ( 83%) 1.8/22 ( 82%) 5/ 6 ( 83%) 3/ 4 ( 75%) 19 35 ( 54%) 3/ 4 ( 75%) 10/11 (91%) 22/30 (73%) 10/11 (91%) ALL 18/21(86%) 59/87 (68%) 18/21 (86%) 56 50 84 190

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_2

Step: 3

blur-text-image_3

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions