(process scores in a text file) Suppose that a text file Exercise13_3.txt contai
ID: 3761751 • Letter: #
Question
(process scores in a text file) Suppose that a text file Exercise13_3.txt contains an unspecified number of scores.Write a c++ program that reads the scores from the file and display their total and average.Scores are seperated by blanks.
Instead of displaying the results on the screen, send the results to an output named using your last name.
In addition to finding the average and total, find the number of grades.
Example:
Contents of Exercise13_3.txt:
70 88 91 95
66 82 71 99 84 57
80 100 93 73 82
70 88 91 95
66 82 71 99 84 57
80 100 93 73 82
Contents of YourLastName.txt:
Your first and last name
Number of grades = 16
Total of all grades = 1231
Average grade = 82.1
70 88 91 95
66 82 71 99 84 57
80 100 93 73 82
Explanation / Answer
#include #include #include using namespace std; int main(){ string fname,lname; char grade='A';'B';'C';'D';'F'; int totalpoints; int pscore1,pscore2,pscore3,pscore4,pscore5; int test1,test2; int paverage; //File Input and Output ifstream fin; ofstream fout; //step 2 fin.open("input.txt"); if(!fin){ coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.