Please help programing in C!!! Ob jectives: The purpose of this assignment, is f
ID: 3764108 • Letter: P
Question
Please help programing in C!!!
Objectives:
The purpose of this assignment, is for students to demonstrate the ability to use
C syntax for 2D array declaration
C syntax and semantics for processing 2D arrays
C syntax and semantics to create user defined functions
C syntax for C file input
C syntax to format output data
C syntax and semantics to create a program that compiles and runs correctly
Comments to annotate code
Problem
You have been hired to develop software to maintain the performance statistics for the tennis pro Marisol Bohen. Your software should track her performance for the 12 months of the year. Each month there are 8 tennis tournaments. She may or may not participate in every tournament. When she does not participate, this is indicated this with a score of 0.
Your software should read Marisol’s score data from an input file- scores.txt, and store the values in a 2D array. It should also facilitate queries on Marisol’s performance to obtain the following:
1. Her score for any given tournament in a given month
2. Her average and maximum score for the year
3. Her average and maximum score for a given month
You will provide the features above by writing functions to compute or retrieve the required information.
When your program is run, it should display a menu of the available features as shown in the sample run. A User will be able to select an option from the menu. This will evoke the appropriate function call. The menu displayed should be as shown in the sample output with options 0-7.
Your solution to this problem should include the following 10 functions:
1. makeArray: This function takes a file pointer and a 2D array of scores as its parameters and updates the array to reflect the score values read from the input file.
2. getScore: This function takes the array of scores, a month and tournament number (both given as integers), and returns Marisol’s score for that particular game. The months are numbered 1- 12.*
3. getMonthMax: This function takes the array of scores, a month (given as an integer *) and returns Marisol’s maximum score for that month.
4. getYearMax: This function takes the array of scores and returns the maximum score made for the whole year.
5. getMonthAvg: This function takes the array of scores, a month (given as an integer *) and returns Marisol’s average score for that month.
6. getYearAvg: This function takes the array of scores and returns the average score made for the whole year.
7. toursMissed: This function takes the array of scores and returns the number of tournaments that Marisol did not participate in for year.
8. displayMenu: This function prints out the set of options available to the users. The display format is as shown in the sample output.
9. processRequest: This function takes the array of scores and an integer representing the option selected by the user. During its execution it also obtains any additional information required to process the user request. It calls the appropriate function and then displays the appropriate result.
10. printArray: This function takes the array of scores and prints out all of the scores stored for the year. The scores should be printed out in the format shown in the sample output.
Submission of Assignment
Your assignment should be submitted via Webcourses by the deadline. No assignments will be accepted via email. Your submission should be a single .c file called tennis.c . Note that you do not have to submit the input file. Your program will be graded using DevC++, so be sure that your submitted code runs correctly in this IDE. If you do not have DevC++ on your personal machine, you may use a computer in any lab to test your code. Remember that any program submitted which does not compile, can only receive a maximum of 30% of the total grade. Depending on the quality of code submitted, the actual grade may be less than the maximum.
Restrictions:
Your program should be written to read an input file named scores.txt and write output to the screen
The scores file will contain 96 integers each separated by at least 1 space character (it may be more than 1).
The data will be terminated by the number 999.
You may assume that all of the numbers in the file are legitimate integer scores.
Remember that the sample input file and screen output, are just samples of possible data that can be used to test your program.
The actual input file used to run your code, will always match the format described in this section, but may be different in content from the
sample input file. For example:
o There may be more or less spaces between the scores
o The distribution of scores obtained will most likely be different
Sample input/output
Your program should run on any input file that matches the format of the sample scores.txt below
26 35 25 92 0 6 47 68 26 72 67 33 84 28 22 36 53 66 23 86 36 75 14 62 43 11 42 5 14 58 0 23 30 87 80 81 13 35 94 45 1 53 14 55 46 19 13 0 25 28 66 86 69 0 81 15 55 60 26 70 22 36 15 67 62 16 71 7 29 92 84 37 2 30 7 5 4 50 0 67 2 53 69 87 8 23 74 58 86 0 78 88 85 12 1 52 999
Explanation / Answer
#include #include #define rows 8 #define cols 12 void makeArray(FILE*,int[][cols]); int getScore(int[rows][cols],int,int); int getMonthMax(int month,int numbers[rows][cols]); int getYearMax(int numbers[rows][cols]); float getMonthAvg(int,int numbers[rows][cols]); float getYearAvg(int numbers[rows][cols]); int toursMissed(int numbers[rows][cols]); void displayMenu(); int processRequest(int numbers[rows][cols],int); void printArray(int numbers[rows][cols]); int main(void) { int numbers[rows][cols]; int choice,end=0; FILE* file; /* declare a FILE pointer */ file = fopen("scores.txt", "r"); /* open a text file for reading */ makeArray(file,numbers); do{ displayMenu(); scanf("%d",&choice); end = processRequest(numbers,choice); }while(end!=-1); fclose(file); return 0; } void makeArray(FILE* file,int numbers[rows][cols]){ int i = 0,j = 0,temp = 0; for (i=0 ; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.