trying to get void getscore() to read a file and report

Jun 30, 2014 at 4:51pm
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

// Function prototype
void getScore(int &);
void calcAverage(int, int, int, int, int);
int findLowest(int, int, int, int, int);
int grades(int, int, int, int, int);
int main()
{
ifstream grades;
grades.open("grades.txt");

int testScr1, testScr2, testScr3, testScr4, testScr5;


getScore(testScr1);
getScore(testScr2);
getScore(testScr3);
getScore(testScr4);
getScore(testScr5);

calcAverage(testScr1, testScr2, testScr3, testScr4, testScr5);

return 0;
}

void getScore(int &score)
{



}

void calcAverage(int s1, int s2, int s3, int s4, int s5)
{
int sum;
int lowest;
double average;


lowest = findLowest(s1, s2, s3, s4, s5);

sum = s1 + s2 + s3 + s4 + s5 - lowest;
average = sum / 4.0;

cout << setw(4) << fixed << showpoint << setprecision(2);
cout << "The avergae of the four highest scores are: " << average << endl;
}

int findLowest(int s1, int s2, int s3, int s4, int s5)
{
int lowest = s1;

cout << "The lowest test score is: " << lowest << endl;

return lowest;
}


this is what I have so far but I a stuck. The name of the file is grades.txt.
I am trying to get the program to read 5 grades from a file and report back lowest grade that will be dropped and average of 4 left. It runs but is not reading the file. Please help. thank you
Last edited on Jun 30, 2014 at 5:47pm
Jun 30, 2014 at 5:10pm
Jun 30, 2014 at 5:46pm
ok I think I understand but I am not finding a way to use the void getscore() to read from the file. The file has 5 grades. The program runs but reports long numbers that I did not input so to me that means that the program is not reading from the file
Jun 30, 2014 at 6:25pm
as keskiverto said, please edit your post and use code tags, as the code you posted is kinda hard to read...

edit: also from what I see, your function getScore does nothing, literally...
Last edited on Jun 30, 2014 at 6:26pm
Topic archived. No new replies allowed.