Golf Tournament

 

 

Chapter 7: Using one-dimensional and two-dimensional arrays

You will be using arrays to track the golf scores for three players. Each of the three players will be playing one round of golf every day for one week. The program needs to track all the scores, determine the average daily score, and determine the highest and lowest score of any player on a single day and which player is the winner of the tournament (who had the most days with the lowest score of the day).

Step 1)

Declare 2 global constants: The number of players (value = 3)
The number of days (value = 7)

In main, declare a one-dimensional string array that will hold the names of 3 players. (make up your own names for your players; all player names MUST contain multiple words; that means you cannot use “cin”).

In main, declare a two-dimensional array that will hold the score for each player for each day. NOTE: Be sure to use the test data from below.

Step 2)

Fill the arrays

Options for filling the arrays:

Option1:

Declare the two arrays (one-dimensional for the three players and two-dimensional for scores), initialize the arrays with the data to be used in the project. Use the test data (see the next page).

Option2:

Declare the player array, initializing the array with the word “none” for all three players.
Declare the two-dimensional array using 0 as the initial values for all 21 days.
Call a function and use a loop to ask the user for the player names.
In the same function, ask the user for the score of each player for the seven days.

Use this format: Enter the number of shots by player #1 on day #1:
Enter the number of shots by player #1 on day #2:
Etc.
Note:
1. You MUST validate input for negative input.
2. Use the test data for input.
3. Option 2 will earn you 4 points extra credit.

Option 3:

1. Read the data from a file
2. Declare the two arrays and read the score data from a file. The player name data is still entered by the user.
3. Create a file with the correct data (using the test data on the next page) and save it to your project as a .txt file.
4. Call a function that reads the file using a loop.
5. Be sure to check if the files exist. Display an error message if it does not exist. NOTE: when declaring the file, you need to make sure that the file has the full directory structure defined (i.e. c:\test\data.txt).
6. Upload .txt files as well as the .cpp code and screenshot.
7. Option 3 will earn you 4 points extra credit

Step 3)

Create a function that prints the contents of the two arrays in this format:

Name Day 1 Day 2 Day 3 Day 4 Day 5 Day 6 Day 7
John Miller 72 71 70 71 69 67 75
Ben Hogan 69 72 64 72 74 66 71
Sam Snead 68 74 73 67 72 70 65

In the function heading, declare both arrays as constant arrays. Format as closely as possible, but don’t obsess too much over perfection.

Step 4)
Create a function that calculates and displays the average score for each player over the seven days. In that function, display the averages with two numbers to the right of the decimal point. Report the results in the following format:
Name Average score
John Miller (report the results)
Ben Hogan etc.
Sam Snead etc.

In the function heading, declare both arrays as constant arrays.

Step 5)
Create a function that determines the one player who shot the lowest score on a given day. Output the results in that function using the following format:
Lowest score of tournament: _Player # _ shot ____ on Day # _____

In the function heading, declare both arrays as constant arrays.
Extra Credit: +1 point for placing the player name in the output above.
Step 6)
Create a function that determines the one player shot the highest score on a given day. Output the results in that function using the following format:
Highest score of the tournament: _Player # __ shot ____ on Day # _____

In the function heading, declare both arrays as constant arrays.
Extra Credit: +1 point for placing the player name in the output above.

Step 7)

Create a function that displays the player who won the tournament. This is defined by the player who had the lowest score on the most number of days. Output the results in that function using the following format:
The winner of the tournament is: _Player #

In the function heading, declare both arrays as constant arrays.
Extra Credit: +1 point for placing the player name in the output above.

 

Notes:

• Use the test data and formatting as suggested above.
• Use good documentation the constants, variables, functions.
• Use variables and function names that are clear and self-explanatory.
• Pass the arrays as constants where appropriate.
• Use good spacing in both the code and the output.

 

Sample Solution

owever, the history of India can not overlook the 200 year British rule over the country. Every aspect of Indian lifestyle, whether it is education, transportation, commerce, or advertising and communications, was affected by the foreign invasion. But, it was in such a time period that type setting shops, also called studios, emerged, marking the beginning of advertising created in India (as opposed to imports from England). These studios were set up for bold type, ornate fonts, fancier, and larger ads. These newspaper studios then trained the first generation of visualizers & illustrators.

The earliest of ads that can be seen, appeared in newspapers, in the form of the latest merchandise from England around the early 1700s. Other goods advertised then were patent medicines; the first brands as we know them today were a category of advertisers.

INTRODUCTION

Advertising has been any business’s most important part since centuries, The very first print advertisement in English got printed in 1472 for selling a book of prayer. It’s very clear that the media today has become a very present force in India and abundance of advertisements is the result of free media. In print advertising history it can be explained by the offers which are posted in newspapers or sent through mail. It is one of the oldest medium of advertising and it has long history. During the time of William Caxton, in 1468, it started, when William promoted a book which had his first printed advertisement. Later in 1704 a person named Joseph Campbell started to include ads in Newsletter of Boston. After this, Benjamin Day got a book printed named New York Sun in the period of 1833, It was a mix of stories and advertising car. Later in 1910 the ‘Edward book of Women home book’ made a magazine ad code.

Since this time period print advertising started giving more attention towards design and glamour. Print advertising was only effective if people see them, when a person look through one or two publications he bent towards getting new details and also his observation starts which gradually increases about the things w

This question has been answered.

Get Answer
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
👋 Hi, Welcome to Compliant Papers.