Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program Steps Add the code in main() to do the following: 1-Create a binary file named HW5-course-XXXXX.dat where XXXXX are the last 5 digits of

Program Steps

Add the code in main() to do the following:

1-Create a binary file named HW5-course-XXXXX.dat where XXXXX are the last 5 digits of your ID. Open the file for writing

2-Create an array of 6 courses (using an array of struct pointers) with the following data:

Name Professor Number of students

CIS02-Computer & Society John Smith 20

CIS03-Business Information System Mary Joe 22

CIS14-Visual Basic Art Lynn 25

CIS18-Introduction to Unix/Linux Edward Ahren 22

CIS22A-Introduction to C++ Hann So 16

CIS22B-Intermediate C++ Tony Nguyen 24

3- Use a loop to write all the array of courses to the binary file HW5-course-XXXXX.dat.

4- Close the file.

5- Open the file HW5-course-XXXXX.dat again for reading

6- Create a text report file named HW5-course-XXXXX.txt for writing and open it.

7-Use a loop to read all the data from the file HW5-course-XXXXX.dat regardless of the number of records, while doing the following steps for each course:

-print the course information to file HW5-course-XXXXX.txt

-calculate the average total student score of each course

= (total score of student 1 + total score of student 2 + .total score of student N) / N

-print the average total student score to HW5-course-XXXXX.txt

8- Close the output report file

Requirements:

-The loop that reads the binary data file in step 7 should be flexible to read any number of records, not just exactly 6 records because users may need to have more courses in the future.

-You can add more functions to the program, but do not modify the already given functions.

-Create a new function named printCourse with an extra second reference parameter of type ofstream (that overloads the existing printCourse() with 1 parameter) to print each course to the output report file.

-Create a new function named printStudents with an extra third reference parameter of type ofstream (that overloads the existing printStudents() with 2 parameters) to print students to the output report file.

Note:

-Function overloading is in chapter 6 and was covered in class previously.

Output on console:

image text in transcribed

Program Output File:

Your output file should look quite similar to the following.

See complete output

Course name: CIS02-Computer & Society

Professor: John Smith

Student name: V836

Scores: 8 16 18 18 6 15 12 19 7 9

Student name: B999

Scores: 0 8 12 8 4 5 11 4 15 13

Student name: X421

Scores: 9 2 7 1 8 14 14 0 20 20

Student name: J556

Scores: 13 0 8 4 6 17 16 5 3 10

Student name: Z343

Scores: 10 12 19 11 14 0 18 3 0 14

Student name: E281

Scores: 17 8 16 4 18 18 16 7 11 8

Student name: Q657

Scores: 20 17 12 19 4 3 11 9 17 0

Student name: W646

Scores: 7 14 17 20 7 3 9 9 20 15

Student name: A651

Scores: 4 8 8 0 4 8 14 2 17 11

Student name: V869

Scores: 11 9 3 3 9 1 4 1 11 16

Student name: W426

Scores: 15 6 4 20 11 12 17 11 5 18

Student name: C692

Scores: 5 13 11 1 7 20 10 0 4 15

Student name: T423

Scores: 4 19 13 13 16 7 0 13 4 11

Student name: V416

Scores: 20 19 2 7 2 9 12 4 5 7

Student name: O263

Scores: 8 16 0 19 9 14 5 8 8 15

Student name: H558

Scores: 0 10 19 7 12 20 10 19 12 17

Student name: T466

Scores: 11 8 0 0 12 11 9 5 20 6

Student name: E313

Scores: 1 8 5 11 13 14 3 20 17 13

Student name: J414

Scores: 11 15 18 2 12 20 10 14 11 10

Student name: E177

Scores: 7 14 20 1 14 20 15 17 2 4

Average total student score: XXX.XX

----------------

Course name: CIS03-Business Information System

Professor: Mary Joe

Student name: XXXXX

..

Average total student score: XXX.XX

reating course output file Hw5-course-Xxxxx. dat losing course output file Hw5-course-XXXXX. dat pening course output file Hw5-course-XXXXX. dat pening course report Hw5-course-XXXXX.txt Reading course input file Hw5-course-XXXXX. dat. riting a course to report Hw5-course-XXXXX. txt riting a course to report HW5-course-XXXXX.txt riting a course to report HW5-course-XXXXX.txt riting a course to report HW5-course-XXXXX.txt riting a course to report HW5-course-XXXXX.txt riting a course to report HW5-course-XXXXX.txt losing report Hw5-course-XXXX.txt Process returned 0 (Ox0) xecution time 0.080 s Press any key to continue reating course output file Hw5-course-Xxxxx. dat losing course output file Hw5-course-XXXXX. dat pening course output file Hw5-course-XXXXX. dat pening course report Hw5-course-XXXXX.txt Reading course input file Hw5-course-XXXXX. dat. riting a course to report Hw5-course-XXXXX. txt riting a course to report HW5-course-XXXXX.txt riting a course to report HW5-course-XXXXX.txt riting a course to report HW5-course-XXXXX.txt riting a course to report HW5-course-XXXXX.txt riting a course to report HW5-course-XXXXX.txt losing report Hw5-course-XXXX.txt Process returned 0 (Ox0) xecution time 0.080 s Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions