Golf Tournament – Essaylink

Get your Assignment in a Minimum of 3 hours

Our academic experts are ready and waiting to assist with any writing project you may have. From simple essay plans, through to full dissertations, you can guarantee we have a service perfectly matched to your needs.

Free Inquiry Order A Paper Now Cost Estimate

 

 

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.
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.

 

The post Golf Tournament first appeared on COMPLIANT PAPERS.

"Is this question part of your assignment? We Can Help!"

"Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!"

Get Started