Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please use printf and scanf C Programming Assignment 10 Due Friday, April 20, 2018 For the program assigned below, submit the following: Hard copy of

please use printf and scanf

C Programming Assignment 10

Due Friday, April 20, 2018

For the program assigned below, submit the following:

Hard copy of the source code and output file

Copy of the source code (.c file), input file, and output file saved as electronic attachments to C Assignment 11 located in Canvas under Assignments.

Observe the usual guidelines regarding the initial comment section, indenting, and so on.

Place function prototypes before function main. Place function definitions following main.

Before each function use comments to explain what the function does.

Do not use any global variables.

The scores for 20 hypothetical students in a class on three tests are shown below.

Student ID Number

Test 1

Test 2

Test 3

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

A labeled table of student Ids, test scores, corresponding student test averages, and letter grades (if calculated for extra credit).

A listing the three test averages just below the columns of test scores.

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:

If the average score is 90% or more, the grade is A.

If the average score is 70% or more and less than 90%, check the third score. If the third score is more than 90%, the grade is A; otherwise the grade is B.

If the average score is 50% or more and less than 70%, check the average of the second and third scores. If the average of the two is greater than 70%, the grade is C; otherwise the grade is D.

If the average score is less than 50% then the grade is F.

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.

The scores for 20 hypothetical students in a class on three tests are shown below.

image text in transcribed

The scores for 20 hypothetical students in a class on three tests are shown below Student ID Number 100 101 102 103 104 105 106 107 108 109 110 Test 2 89 76 95 58 82 67 84 95 80 60 62 64 84 91 93 90 65 42 63 58 Test 1 57 75 90 35 Test 3 72 80 85 50 62 75 90 98 64 82 93 56 80 72 65 50 78 70 78 81 92 29 56 79 94 112 113 114 115 116 86 69 100 45 50 71 87 118 119 The scores for 20 hypothetical students in a class on three tests are shown below Student ID Number 100 101 102 103 104 105 106 107 108 109 110 Test 2 89 76 95 58 82 67 84 95 80 60 62 64 84 91 93 90 65 42 63 58 Test 1 57 75 90 35 Test 3 72 80 85 50 62 75 90 98 64 82 93 56 80 72 65 50 78 70 78 81 92 29 56 79 94 112 113 114 115 116 86 69 100 45 50 71 87 118 119

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Statistical And Scientific Database Management International Working Conference Ssdbm Rome Italy June 21 23 1988 Proceedings Lncs 339

Authors: Maurizio Rafanelli ,John C. Klensin ,Per Svensson

1st Edition

354050575X, 978-3540505754

More Books

Students also viewed these Databases questions