I have a problem. I got my file to open but I don't know how to modify the file and have the output I need. Here is my code so far

#include <fstream>
#include <iostream>
#include <cstdlib>

int main()
{
    using namespace std;
    ifstream input;
    ofstream output;

    input.open("input.txt");
    if (input.fail())
    {
        cout<<"Input file opening failed.\n";
        exit(1);
    }

    output.open("grade.txt");
    if (output.fail())
    {
        cout<<"Output file opening failed.\n";
        exit(1);
    }

    input.close();
    output.close();

    return 0;
}

i'm supposed to add the total of scores...average them and have the program tell me who has the highest and lowest averages of the students.

I have a problem. I got my file to open but I don't know how to modify the file and have the output I need.

Well, the first thing you have to add is reading the file input.txt.

Edited 6 Years Ago by WaltP: n/a

The input file looks like this:

DAN 100 70 85
JANE 78 82 90
PETER 82 84 91
MINIE 98 100 75
JOSEPH 71 62 100
CHRISTOPHER 91 75 82
BEN 54 84 77

After I read the input file and add everything its supposed to have their total, average, letter grade and show us who has the lowest grade and who has the highest grade.

This article has been dead for over six months. Start a new discussion instead.