Starting from:
$35

$29

Assignment 01 Solution

Your program is to use two data structures to read in student grade data, perform some calculations, sort the students in ascending order by average, determine some class statistics, and output the results. The first data structure is classStats and should have variables mean (float), min (float), max (float), median (float), and name (character pointer). You will need to create this structure yourself, placing it above main() in lab8assignmentA.c and create one variable of type classStats (not a pointer) in your main program.

The second data structure is called student and will have variables first (character pointer), last (character pointer), exam1 (integer), exam2 (integer), exam3 (integer), and mean (float). This structure is in the file student.h. Take a moment to study this structure to understand it before using it. You will need to create an array of 19 student pointers and will need to allocate space for each in your main program using malloc().

The data file contains the name of the course followed by 19 students, each student having three exam grades. Use the array of student pointers to store the information as read in using scanf. An example data file is below:

       CSCE1040
Sanders
75 89 67
Erica
Kelley
Cummings
74 70 79
Jamie
Reynolds
64 52 66
Shawna
Huff
80 88 61
Muriel
Holmes
81 74 79
Marion
Harmon
77 64 69
Catherine
Moss
51 80 73
Kristin
Fernandez 86 69 81
Elsa
Alvarado
63 77 67
Cora
Spencer
76 79 71
Valerie
Olson
85 78 79
Anne
Singleton 85 87 65
Rene
Boone
85 85 77
James
Morgan
69 86 51
Cedric
Haynes
72 73 88
Elijah
Snyder
65 92 91
Roger
Howard
79 95 71
Archie
Black
70 81 63
Melvin
Watkins
66 67 72
Use the three grades to determine the student's mean and store it with the name and exam grades in thePagestudent1 of2 (A) structure. Assumed each exam is weighted the same. Once all the students are read in and the averages determined, sort

 the students using the bubble sort code in bubble.c, which takes an array of student pointers and the array size as

arguments. Take a moment to study bubble.c to understand how it works before using it. After sorting the students based on mean, find the mean, minimum, maximum, and median of the grades and store them in the classStats structure.

Use printf to output the data. Your output should appear as below (include the line of digits), which displays the class statistics and the student averages. Do not worry about rounding. If some students are out of order because they have the same  mean, do not worry about it as long as you used the bubble sort.

123456789012345678901234567890123456789012345678901234567890 CSCE1040 MEAN: 74.91 MIN: 60.66 MAX: 82.66 MEDIAN: 76.33

          
Jamie
Reynolds
60.66
 
Catherine
Moss
68.00
 
Melvin
Watkins
68.33
 
James
Morgan
68.66
 
Elsa
Alvarado
69.00
 
Marion
Harmon
70.00
 
Archie
Black
71.33
 
Kelley
Cummings
74.33
 
Cora
Spencer
75.33
 
Shawna
Huff
76.33
 
Erica
Sanders
77.00
 
Cedric
Haynes
77.66
 
Muriel
Holmes
78.00
 
Kristin
Fernandez
78.66
 
Anne
Singleton
79.00
 
Valerie
Olson
80.66
 
Roger
Howard
81.66
 
Rene
Boone
82.33
Elijah
Snyder
82.66
 
Hint 1: Break the programming into smaller phases. Read in the data and output it to make sure it works. Then add code to calculate the student averages. Next, add code to sort the students using the bubble sort. After that, add code to determine the  class statistics. Finally, output the results.

Hint 2: To compile your code, you can use g

*.cSS to compile all .c files in your directory at one time.

Page  2 of  2 (A)

More products