#include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; double avg(double,double,double,double,double,double,double,double); int main () { ifstream inFile; inFile.open("scores.txt"); ofstream outFile; outFile.open("summary.txt"); string type; double score1, score2, score3, score4, score5, score6, score7, score8; inFile >> type >> score1 >> score2 >> score3 >> score4 >> score5 >> score6 >> score7 >> score8; outFile << setw(14) << left << type << " " << avg(score1,score2,score3,score4,score5,score6,score7,score8)*10 << endl; return 0; } double avg(double s1, double s2, double s3, double s4, double s5, double s6, double s7, double s8) { return (s1+s2+s3+s4+s5+s6+s7+s8)/8; } |
Create a program which will read from a file named "scores.txt" containing a student's scores for this class. Assume the following about this file: The first line contains 8 quiz scores, each out of 10. The second line contains 8 homework scores, each out of 10. The third line contains 8 classwork scores, each out of 10. The fourth line contains 3 project scores, each out of 20. The fifth line contains 2 exam scores, each out of 50. Note: Because you know how many lines are in this file, and the number and types of each score, you do not need a while loop to read in the data. Your program should calculate: a quiz percentage, homework percentage, classwork percentage, project percentage, and exam percentage out of the total number of points possible for each category. Using the information from our class syllabus on the weight of each category, use these percent- ages to come up with a score from 0 to 100 representing the student's work for the semester. Your program should place all of this information in a table in a file named "summary.txt". |
|
|
|
|
|
|
|
|
|
|
|
|
|
|