Programming Project 4
Bowling Score Statistics Keeper
int main() { int scoreList [MAX_PLAYERS]; /* Array to store bowling scores */ int numberOfPlayers = 0; /* Total number of scores entered */ int averageScore = 0; /* Average bowling score */ int winningScore = 0; /* The winning bowling score */ printf("\nWelcome to CMSC104's Bowling Statistics Program!\n\n"); /* Fill array with bowling scores */ numberOfPlayers = FillBowlingScoreList (scoreList); /* Print the bowling scores */ PrintBowlingScoreList (scoreList, numberOfPlayers); /* Find and print the winning score */ winningScore = FindWinner (scoreList, numberOfPlayers); printf("The winning score was %d.\n\n", winningScore); /* Calculate and print the average bowling score */ averageScore = CalculateAverageScore (scoreList, numberOfPlayers); printf("The average score was: %d.\n\n", averageScore); /* Find and print the players who had scores above the average */ ProcessAboveAverage (scoreList, numberOfPlayers, averageScore); return 0; }
You MUST use the main() function exactly as it is given. However, you need to add the following code before main:
To use the data file as input to your program, you will use Linux redirection.
By using redirection, you can tell Linux to read data from a file rather
than from the keyboard. The scanf
statement that you use in
your program will look exactly the same as it would if you were getting
your input from the keyboard. But since you will be getting the values
from a file instead of from a user typing at the keyboard, you will not
need to prompt the user.
When you run your program, use the following command:
a.out < scores.datThis is how Linux redirection is done. It is saying to run your executable file using the file
scores.dat
as input.
You will need to copy the file scores.dat
into your directory.
To do this, go to the directory where you would like to store
scores.dat
. Then, use the following command to copy
scores.dat
into the directory:
cp /afs/umbc.edu/users/d/b/dblock/pub/CS104/Proj4/scores.dat .Notice that the space and period at the end of the command are part of the command.
Here is a example of what the input data file could look like:
211 198 234 179 207 118 186 0
You will also find proj4.c
in the directory with
scores.dat
. You can copy it to your own directory
following the above directions.
linux2[3]% gcc -ansi -Wall proj4.c linux2[4]% cat scores.dat 211 198 234 179 207 118 186 0 linux2[5]% a.out < scores.dat Welcome to CMSC104's Bowling Statistics Program! The following scores were entered: Player 1: 211 Player 2: 198 Player 3: 234 Player 4: 179 Player 5: 207 Player 6: 118 Player 7: 186 The winning score was 234. The average score was 190. The following players played an above average game: Player # Score ---------- ---------- 1 211 2 198 3 234 5 207 linux2[6]%Your output does not have to match the sample exactly, with a few exceptions:
Here is a sample submission command. Note that the project name starts with uppercase 'P'.
submit cs104 Proj4 proj4.c
To verify that your project was submitted, you can execute the following command at the Unix prompt. It will show the file that you submitted in a format similar to the Unix 'ls' command.
submitls cs104 Proj4