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:testdata.txt).
  6. Upload .txt files as well as the .cpp code and screenshot.
find the cost of your paper

This question has been answered.

Get Answer