Reading from a text file

Write a program that reads students' names followed by their test scores. the program should output each student's name followed by the test scores and the relevant grade. It should also find and display the highest test score and the name of the student having the highest test score.

Basically I need to put a txt file in my folder, then the program should read the name of students and their scores from that text file.

This is what is in the text file:
Mark Simpsonite 95
Mary Marvelous 100
Milton Hamilton 82
Marvin Wilshire 76
Myrtle Millford 92

The name of this text file is scores

This is my code so far and it's not complete (I haven't written the code for Grade (A, B, C, D, F) and who has the highest score). Also there are some extra stuff in the code so just ignore those please.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

const int MAX = 5;


int main ()
{

    const int MAX = 5;
    ifstream inFile;
    ofstream outFile;
    int ctr, scores, total = 0;
    string names[MAX];


	 inFile.open("scores.txt");
    if (!inFile)
    {
        cout << "Could not open scores.txt." << endl;
        return false;
    }
    else
    {
        while (!inFile.eof())
        {
            inFile >> scores;          
        }
        cout << "Name of the students and score is: " << scores << endl;

        inFile.close();
    }
}


The program builds and all but it won't display anything in the command prompt, it won't display the name of the students and their scores. Why is that? SO could you guys please help me and solve it? Thanks , hope I was clear enough.
Last edited on
Topic archived. No new replies allowed.