Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that tracks the medals won by countries participating at the Olympic Games. C + + Your program should use a structure that
Write a program that tracks the medals won by countries participating at the Olympic Games. C
Your program should use a structure that keeps the following data for a given country:
Country Name
Number of gold medals awarded
Number of silver medals awarded
Number of bronze medals awarded
The program should maintain an array of countries, initialized with the following data.
Country Gold Silver Bronze
Australia
Canada
China
Great Britain
Japan
Netherlands
Russia
USA
When the program runs, it should repeat a loop that performs the following steps:
Print a numbered list of the Countries with column headers and corresponding data for each country on a separate row see "Sample execution" below for the exact format The "Total" column records the total number of medals awarded to that country. Use the following code to print the header. Infer the formatting of each row from this code.
cout left
setwN
setw "Country"
right
setw "Gold"
setw "Silver"
setw "Bronze"
setw "Total"
endl;
The user is prompted enter the country number or quit enter to quit
If the country number is not then the user is prompted to enter the medal type awarded G for gold, S for silver, and B for bronze And, if the input is valid, the medal count for the indicated country is incremented appropriately.
The loop repeats until the user enters to quit.
When the user quits the program, the program should display a message indicating the total medals awarded to all countries, and which country has the most Gold medals.
Your program must include these four functions
One to display the table of countries, given the array of Countries.
One to update the medal counts: given the array of Countries, a country number, and a medal character, it increments the appropriate medal count. This function should NOT contain a loop, it should NOT do any inputoutput The main program loop should be in main. If the country number or medal character is invalid it should do nothing not output an error message
One to determine the total number of medals awarded, given the array of Countries, it should NOT do any inputoutput
One to determine which country has the most gold medals, given the array of Countries, it should NOT do any inputoutput
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