Question: Please write a c file For the program assigned below, submit the following: Hard copy of the source code and output file Copy of the
Please write a c file
For the program assigned below, submit the following:
Observe the usual guidelines regarding the initial comment section, indenting, and so on.
The scores for 20 hypothetical students in a class on three tests are shown below.
Student ID Number | Test 1 | Test 2 | Test 3 |
100 | 57 | 89 | 72 |
101 | 75 | 76 | 80 |
102 | 90 | 95 | 85 |
103 | 35 | 58 | 50 |
104 | 88 | 82 | 62 |
105 | 64 | 67 | 75 |
106 | 82 | 84 | 90 |
107 | 99 | 95 | 98 |
108 | 93 | 80 | 88 |
109 | 56 | 60 | 65 |
110 | 80 | 62 | 50 |
111 | 72 | 64 | 78 |
112 | 77 | 84 | 70 |
113 | 86 | 91 | 78 |
114 | 69 | 93 | 81 |
115 | 100 | 90 | 92 |
116 | 45 | 65 | 29 |
117 | 50 | 42 | 56 |
118 | 71 | 63 | 79 |
119 | 87 | 58 | 94 |
Write a program that will compute statistics on the test scores above.
Create a project in Visual Studio and add a new .c file. From the Project pull down menu go to Add New ItemUtilityTextFile. Give the file a name and click Add. Copy and paste into the file the data table above, containing on each line the student ID number and the three test scores for that student, separated by spaces. Do not include column headings.
In function main declare but do not initialize a one-dimensional array of Ids with 20 elements and a two dimensional array of test scores with 20 rows and 3 columns. The number of rows and columns may be declared as defined constants. (Alternatively, you may put Ids and scores all in the same 2-dimensional arrayas long as you remember that Ids are in column 0 and test scores are in columns 1, 2, and 3.) Call the following functions from main (using function names of your own choosing.
Function readData reads the Ids and test scores from a data file.
Within the function you may declare a pointer to a file and then do the following: Open your text file for reading and assign the address returned from the fopen command to the file pointer. Check to see that the file opened successfully. Use fscanf in the appropriate loop structure to read in the Ids and scores. Close the file.
Required function parameters are the one-dimensional array of IDs and the two-dimensional array of scores. Although it is preferred coding to include the number of rows and columns of test scores as function parameters, it is permissible for this assignment just to use the symbolic constants for ROWS and COLS throughout. (If you cannot get this function to work you may initialize the array(s) at declaration in function main with a 2-point deduction in your score.)
Function testAverages receives the 2-D array of test scores and calculates the average of each test. Test averages should be floating point numbers and they should be placed in a 1-D array. The array of test scores and the array of test averages are the function parameters. Although it is preferred coding to include the number of rows and columns of test scores as function parameters, it is permissible for this assignment just to use the symbolic constants for ROWS and COLS throughout.
Function studentAverages receives the array of test scores and calculates the average of the three test scores for each student. Student averages should be floating point numbers and they should be placed in a 1-D array. The array of test scores and the array of student averages (and number of rows and columns if not using symbolic constants) are the function parameters.
Function printResults should print the results to a file. In the function declare a pointer to a file for writing. Open the file and check to see that it opened successfully. Write the following output to the file using fprintf.
Averages and standard deviation may be printed with one decimal digit.
Close the file.
Extra Credit:
For two points extra credit determine a letter grade for each student according to instructions below. Print letter grades in the printResults function beside the test averages for each student.
Function letterGrade receives the array of test scores and array of student averages and calculates an array of letter grades for the students according to the following scale:
The array of test scores, array of student averages, and array of grades (and number of rows and columns if not using symbolic constants) are the function parameters.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
