Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that records and displays information about a roster for a baseb

ID: 3562276 • Letter: W

Question

Write a program that records and displays information about a roster for a baseball or softball team. The information recorded includes first name, last name, position, and batting average. The batting average is the percent of the at-bats for a player expressed as a decimal value between zero and one. The positions are pitcher (P), catcher (C), first base (1B), shortstop (SS), second base (2B), third base (3B), left field (LF), right field (RF), and designated hitter (DH).

Write the following four functions:

One function to read the number of players and the information about each player and store the information in a dynamically allocated array of structures representing the roster.

One function to sort the roster by the players' last names. Any players with the same last name should be ordered by first name as well.

One function to sort the roster by the players' batting averages. It should be sorted from highest to lowest.

One function to display all of the information stores in the roster.

All function parameters must be pointers.

Sample Run Your output should look similar to the following. Things in bold are typed by the user. How many players are on your roster? 4 Enter the following information for player #1 First name: Ryan Last name: Braun Position: RF Batting average: .275 Enter the following information for player #2 First name: Carlos Last name: Gomez Position: CF Batting average: .283 Enter the following information for player #3 First name: Jonathan Last name: Lucroy Position: C Batting average: .299 Enter the following information for player #4 First name: Scooter Last name: Gennett Position: 2B Batting average: .296 Please choose one of the following options 1. Sort roster by name 2. Sort roster by batting average (highest to lowest) 3. Display roster 4. Exit the program 3Ryan Braun (RF, 0.275) Carlos Gomez (CF, 0.283) Jonathan Lucroy (C, 0.299) Scooter Gennett (2B, 0.296) Please choose one of the following options 1. Sort roster by name 2. Sort roster by batting average (highest to lowest) 3. Display roster 4. Exit the program

Explanation / Answer

#include #define PLAYERS_NO 19 typedef struct { char name[20+1]; char lastName[25+1]; int atbat; int hits; int walks; int runs; float batavg; } Profile; int main(int argc, char** argv) { Profile stats[PLAYERS_NO]; int i; FILE* dataFile; int playerNo; Profile tmpProfile; int games = 0; for(i=0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote