Question: write a code in c++ Create a structure called Student with the following data elements: (5 points) name - string house - string year -

write a code in c++

Create a structure called Student with the following data elements: (5 points) name - string house - string year - integer grades - array of doubles of size 5 average - double

Create a structure called Course with the following data elements: (5 points) subject - string year avg - array of doubles of size 7

Open the file students.txt. The first line of this file is an integer that will tell you the number of students in the gradebook. Read in size from the file. (2 points) 1

Create a dynamic array of Student structures with size number of elements. (5 points)

Create an array of Course structures of size 5. This one should be local to main, and not dynamic. (4 points)

Continue reading from students.txt into the array of Student structures. Each following line of the file will be of the format name * house * year Please make sure you watch out for the newlines while reading. (10 points)

Open the file grades.txt. This file will have one less line than the student file. Each line of this file will have 5 doubles. The grades on line k will be the grades for the student on line k+1 of the student file. The grades will always be in the order - Charms Defense Herbology Potions Transfiguration (space separated) (3 points)

Read data from the grade file into each students record. Calculate each students individual average and store it in the structure. (15 points)

Calculate the count of students in each year. (6 points)

Iterate through the array of students and use this data to calculate the average for each subject for each of the 7 years at Hogwarts. (12 points)

Open a file called report.txt. Use the student array to print the name of the student and their grade average into this file. (10 points)

Once all the student information has been printed, print the average of each subject by year into the file. (15 points)

Delete the dynamic array of students. (3 points)

You can use the sample files given here to test your code.

You need not check for any errors. You can assume that the data in the files will be exactly as expected.

Please include comments wherever appropriate. (5 points)

Write a function called sort, that would take in 3 parameters - the array of Students, its size and an integer called choice. If the choice were odd, sort the students by name. If the choice were even, sort them by house. The order in the same house is immaterial. Call this function before printing to the file. You can pass in 1 or 0 for the third parameter to test the odd or even case. You can use the insertion sort algorithm given in Homework 5. If you do decide to complete this part, the first part (student name and average) of your output will be different from the above output. It will be the same values, ordered differently (50 points).

write a code in c++ Create a structure called Student with the

You need to use dynamic memory allocation. Allocating a regular array for the Student records will result in loss of points.

Please make sure that youre conforming to specifications (program name, print statements, expected inputs and outputs etc.).

No global variables (variables outside of main() )

All input and output must be done with streams, using the library iostream

You may only use the iostream, fstream, and the cstring. string and cctype libraries (you do not need any others for these tasks)

NO C style printing is permitted. (Aka, dont use printf).

Transfiguration Year 1: 51 students.tx Herbology Year 1: 91 Charms Year 1: 52 Year 2: 63.25 Year 2: 80.5 Year 2: 50.5 Year 3: 47 Year 4: 58 Year 5: 60. Year 5: 89 Year 6: 36 Year 7: 84.5 Year 7: 33.5 Year 7: 64.5 grades.txt report.txt Bronwen Bennett 66.4 12 Bronen BennettHufflepuff3 52 51 91 31 51 Edward Kerley 55.2 Edward Kerley * Slytherin * 1 Linda Fawcett *Hufflepuff * 6 Reginald Shipuay * Gryffindor * 4 75 66 37 89.5 67Ann Trevithick 66.9 Ann Trevithick Ravenclaw*7 Michael Hennessey * Gryffindor * 2 32 73 31.5 85 35 Stephen Perkins 51.3 Stephen Perkins * Slytherin *

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!