Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m having trouble trying to display the output of the fstream File below. The

ID: 3558880 • Letter: I

Question

I'm having trouble trying to display the output of the fstream File below. The information that it suppose to retrive is in note pad file with the following:

Andrew Miller 87.50 89 65.75 37 98.50

Im trying to get the average test scores but so far the only thing i get on the display screen is "Processing Data". The program written is below:

#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>

using namespace std;

int main()
{
    //Declare variables: step 1
    ifstream inFile;
    ofstream outFile;

    double test1, test2, test3, test4, test5;
    double average;

    string firstName;
    string lastName;

    inFile.open("test.txt");
    outFile.open("testavg.out");

    outFile << fixed<< showpoint;
    outFile<< setprecision(2);

    cout<<"Processing Data"<<endl;

    inFile>> firstName >> lastName;
    outFile << "Student Name:"<< firstName
            << " " << lastName << endl;

    inFile >> test1 >> test2 >> test3 >> test4>> test5;
    outFile << "Test Scores:" << setw(6)<< test1 << setw(6) << test2 << setw(6)<< test3
            << setw(6) << test4 << setw(6) << test5 << endl;

    average = (test1 + test2 + test3 + test4 + test5) / 5.0;

    outFile << "Average test score:" << setw(6) << average << endl;

    inFile.close();
    outFile.close();

    return 0;
    }

Explanation / Answer

that data is processed and displays "Processing Data"

because the output is taken into "testAvg.out " file.

Check your testAvg.out file

it contains

Student name: Andrew Miller

Test scores: 87.50 89 65.75 37 98.50

Average test score : 75.55

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote