Question
Write a program that records and displays league standings for a baseball league. The program will ask the user to enter five team names, and
Write a program that records and displays league standings for a baseball league. The program will ask the user to enter five team names, and five win amounts. It will store the data in memory, and print it back out sorted by wins from highest to lowest.
The sample output from your program should look approximately like this (user input in orange):
Enter team #1: Padres
Enter the wins for team #1: 75
Enter team #2: Dodgers
Enter the wins for team #2: 91
Enter team #3: Giants
Enter the wins for team #3: 92
Enter team #4: Rockies
Enter the wins for team #4: 65
Enter team #5: Diamondbacks
Enter the wins for team #5: 70
League Standings:
Giants: 92
Dodgers: 91
Padres: 75
Diamondbacks: 70
Rockies: 65
Requirements
The data must be stored in two parallel arrays: an array of strings named teams, and an array of ints named wins. These arrays must be declared in the main() function. You can assume that the league has five teams, so each of the arrays can have five elements.
As usual, you may not use any global arrays or global variables.
All of the user input must be done in a function named initializeArrays. It must have the following signature:
void initializeArrays(string names[], int wins[], int size)
You must also write two more functions: one to sort both arrays, and one to display the final (sorted) list of team names and scores. They must have the following signatures:
void sortData(string names[], int wins[], int size)
void displayData(string names[], int wins[], int size)
The main function should be very short. It should just declare the arrays and then invoke these three functions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started