Question
*********************************************************************** bubble.cpp #include #include student.h void bubble(student *array[], int size) { int x; int y; student *temp = NULL; for(x = 0; x for(y =
***********************************************************************
bubble.cpp
#include
#include "student.h"
void bubble(student *array[], int size)
{
int x;
int y;
student *temp = NULL;
for(x = 0; x
for(y = 0; y
if(array[y]->mean > array[y+1]->mean) {
temp = array[y+1];
array[y+1] = array[y];
array[y] = temp;
}
}
}
return;
}
~
*******************************************************************************************
bubble.h
void bubble(student *array[], int size);
****************************************************************************
grades
CSCE1040
Erica Sanders 75 89 67
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
***************************************************************************
hwk1.cpp
// DOCUMENTATION GOES HERE
#include
#include
#include "student.h"
#include "bubble.h"
int main()
{
// ENTER YOUR CODE HERE
return 0;
}
~
**************************************************************************
student.h
typedef struct student_info {
char *first;
char *last;
int exam1;
int exam2;
int exam3;
float mean;
} student;
***********************************************************************************
**************************************************************************
There are files to get you started on this assignment located in dmk0080/public/1040/hwk/one/versionA/ grades -the data file student.h structure to hold the student information bubble.h -bubble sort function prototype bubble.cpp -bubble sort that sorts an array of student pointers hwkl cpp-a main program to get you started 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 hwk1.cpp 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 (ihteger), and mean (float). This structure is in the file student Take a moment to study this structure to understand it before using it. You will need to create an array of 19 student m3 (integer), and mean (float). This structure is in the file student.h pointers and will need to allocate space for each in your main program using malloc O 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 Erica Kelley Jamie ShawnaHuff Murie1 Marion Catherine Moss Kristin Fernandez 86 69 81 Elsa Sanders 75 89 67 Cummings 74 70 79 Reynolds 64 52 66 2 80 88 61 81 74 79 77 64 69 51 80 73 Holmes Ha rmon Alvarado 63 77 67 2 02 h ( t) sal- u f. none f. bn it n er e p 9- aa ta in ol 7961993171957181132 0 7 0 6 7 6 7 8 6 7 7 6 7 5 8 9 767 9028440979875632517 875876867778887998 drne r of 5440171636555925900 7768875867888676776 rn.I sn nae et nsrd n arcn1eaeerki snanogng ta t ch en siarii Ecliw2.1 h s a a e e e e rjehv xmd le rrtisrl RJCERAM Use the three grades to determine the student's mean and store it with the name and exam grades in the student 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 clas 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. 123456789012345678 901234567890123456789012345678901234567890 CSCE 1040 MEAN: 74.91 MIN: 60.66 MAX: 8.66 MEDIAN: 76.33 Jamie Reynolds 60.66 Moss 68.00 Watkins 68.33 Morgan 68.66 Alvarado 69.00 Harmon 70.00 Black 71.33 KelleyCummings 74.33 Spencer 75.33 Huff 76.33 Sanders 77.00 Haynes 77.66 Holmes 78.00 Kristin Fernandez 78.66 Anne Singleton 79.00 olson 80.66 Howard 81.66 Boone 82.33 Snyder 82.66 Catherine Melvin James Elsa Marion Archie Cora Shawna Erica Cedric Muriel Valerie Roger Rene Elijah Shawna Huff 76.33 Erica Sanders 77.00 Haynes 77.66 Hoimes 78.00 Kristin Fernandez 78.66 Anne Singleton 79.00 Olson 80.66 Howard 81.66 Boone 82.33 Snyder 82.66 Cedric Muriel 5 Valerie Roger Rene Elijah 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++ *cpp to compile all cpp files in your directory at one time. NOTE: You are not allowed to modify the bubble sort code, nor should you include any of the bubble files in your upload. We will compile with our own copies of these files. Please zip you files into a HW1.zip file and upoad this to Canvas for the graders convenienceStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started