You will develop a C++ program to store and manage information about baseball players.  The program will read the following information for each player in the data file:   player’s name (string) team identifier (string) games played (integer) at bats (integer) runs scored (integer) hits (integer) doubles (integer) triples (integer) homeruns (integer)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question

You will develop a C++ program to store and manage information about baseball players.  The program will read the following information for each player in the data file:

 

player’s name (string)

team identifier (string)

games played (integer)

at bats (integer)

runs scored (integer)

hits (integer)

doubles (integer)

triples (integer)

homeruns (integer)

 

Separate parallel vectors should be used to store the Player’s name and the Team identifier.

For each player, your program will compute the batting average and the slugging percentage.  Those computed values will be stored in separate corresponding parallel arrays. The following formulas will be used for those computations:

 

singles = hits - (doubles + triples + homeruns)

total bases = singles + 2*doubles + 3*triples + 4*homeruns

batting average = (hits) / (at bats)

slugging percentage = (total bases) / (at bats)

 

A player with zero at bats is defined to have a batting average and slugging percentage of zero.

Note that only name, team identifier, batting average and the slugging percentage are stored and retained in the vectors and arrays.

  1. The program will recognize the following commands:

 

QUIT

INPUT filename

TEAM identifier

REPORT n BATTING

REPORT n SLUGGING

 

The program will recognize commands entered with any mix of upper and lowercase letters.

The program will be operated interactively:  it will prompt the user and accept commands from the keyboard and continue until QUIT is entered.

 

If the user enters an invalid command, the program will display an appropriate message and prompt the user to enter another command.

 

  1. The “QUIT” command will halt execution.

 

  1. The "INPUT" command will be followed by a string representing the name of an input file.  The program will discard the current data set stored in memory, and then process the input file as the source for a new data set (open the file, read the file and for each line store the data in the appropriate vectors or arrays.

 

If the user enters an invalid file name, the program will display an appropriate message and prompt the user to enter another file name.  The program will halt after the user enters an invalid file name three consecutive times.

 

  1. The "TEAM" command will be followed by a string representing a team identifier.  The program will display all information about all players on that team, in alphabetical order.

 

The information will be displayed in tabular form.  The fields will be identified using column headers, and the fields will be aligned beneath the headers.

 

If the user enters an invalid team identifier, the program will display an appropriate message and prompt the user to enter another command; the program will not display an empty table.

 

  1. The "REPORT" command will be followed by an integer number and a string (one of "HITS", "BATTING" or "SLUGGING").

 

If the user enters an invalid command, the program will display an appropriate message and prompt the user to enter another command; the program will not display an empty report.

 

For each report, the program will display all information about the top "n" players in a given category:

 

BATTING -- batting average

SLUGGING -- slugging percentage

 

The reports will be sorted from highest to lowest value in the category.

 

The information will be displayed in tabular form.  The fields will be identified using column headers, and the fields will be aligned beneath the headers.  All real values will be displayed with three digits of precision following the decimal point.

 

  1. The program will display appropriate messages to inform the user about any unusual circumstances.

 

  1. The program will consist of at least four meaningful functions.  Communication between functions will occur via parameters and return values; you may not use any global variables.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education