A Very Grading Problem
Programming Assignment
Write a program to provide a report of student grades. Each student is given four exams. The final grade of each student is determined by calculating the weighted average of all the exams. Your report should show the average of each student, the class average, and the maximum and minimum grades for the class.
The first set of data input contains the weights (proportions) for the four exam grades. Next, input the number of students in the class. The set of data input for each student contains the following information:
-- Student's name
-- Student's ID
-- Grade for exam 1
-- Grade for exam 2
-- Grade for exam 3
-- Grade for exam 4
Use the following test data:
-- weights for exams: .10, .20, .25, .45
-- number of student: 15
-- first student record: 101101032, 75, 87, 79, 92
-- make up the rest yourself.
Your output should be neat and readable with appropriate headings.
Version A. (As above)
Version B. Using Input / Output Files. Further instructions:
Input data from the below.
Create a .DAT file for this purpose: Copy the lines below into a text file using Notepad. Then save the file with a .DAT extension.
=========================================
Object-Oriented_Programming
Spring2025
0.15 0.25 0.25 0.35
123456789 Archer Lew 99 62 101 89
111111111 Bond James 100 98 99 89
101010101 Burke Amos 65 77 88 98
222222222 Chambers Pat 44 84 88 101
999999999 Chambers Diane 70 32 90 95
333333333 Clousseau Inspector 42 65 85 54
444444444 Ed Mister 88 99 77 99
666666666 Hammer Mike 88 87 98 78
111222333 Hope Matthew 89 90 80 87
777777777 Kent Clark 99 99 98 99
555555555 Kramer Cosmo 98 87 76 65
000111222 Marlowe Philip 78 76 65 67
888888888 Rockford James 89 78 87 89
444555666 Sunnydale Buffy 87 32 78 92
777888999 Wolfe Nero 100 100 99 100
================================
Here are some things you will need:
#include <fstream>|
ifstream infile ("d:\\students.dat"); //input data file
ofstream outReport ("d:\\report.txt"); //output text file – Report
Question - why double \\ ?
use infile>> to read from input file
use outReport<< to send output to report file
Note that "d:" assumes you have the data on a thumb drive (it may not be d: on your computer)
You could also set up a folder on your local computer, for example: "c:\\IOfiles\\students.dat"
Just in case you have made a mistake with the file – file is missing, name is wrong, path is wrong, etc – use the following test code before you input or output:
if (!infile) //testing file – do the same for outfile
cerr << "Error: could not open input file\n";
else { //files OK - do rest of program
…
…
}