I need some help reading in a file that has a column with the student's name and then a column with their score.
I need to input this into 2 seperate arrays. One for the names and one for the scores.
I have to use a String Array and a Int Array. I can't figure out how to get it into a String array. I keep getting errors.
Any help would be greatly appreciated!!!
This is what I have so far:
#include <iostream>
#include <fstream>
#include <cstring>
#include <iomanip>
#include <cmath>
using namespace std;
ofstream fout;
ifstream fin;
class StudentStat
{
private:
int Size;
string Names[20];
int Scores[20];
float Avg,
StDev,
Median;
int High_Score,
Low_Score,
Range;
void Storem();
public:
void Input();
void Calc_Avg();
void Calc_StDev();
void Calc_Median();
void range();
void Calc_HighLowRan ge();
void Output();
};
void StudentStat::In put()
{
for(int i=0;i<20;i++)
{
fin>>Names[i];
fin>>Scores[i];
cout>>Names[i];
cout<<Scores[i];
}
}
int main()
{
StudentStat Studobj;
fin.open("EvenC lass.txt");
while(!fin.eof( ))
{
Studobj.Input() ;
}
fin.close();
return 0;
}
I need to input this into 2 seperate arrays. One for the names and one for the scores.
I have to use a String Array and a Int Array. I can't figure out how to get it into a String array. I keep getting errors.
Any help would be greatly appreciated!!!
This is what I have so far:
#include <iostream>
#include <fstream>
#include <cstring>
#include <iomanip>
#include <cmath>
using namespace std;
ofstream fout;
ifstream fin;
class StudentStat
{
private:
int Size;
string Names[20];
int Scores[20];
float Avg,
StDev,
Median;
int High_Score,
Low_Score,
Range;
void Storem();
public:
void Input();
void Calc_Avg();
void Calc_StDev();
void Calc_Median();
void range();
void Calc_HighLowRan ge();
void Output();
};
void StudentStat::In put()
{
for(int i=0;i<20;i++)
{
fin>>Names[i];
fin>>Scores[i];
cout>>Names[i];
cout<<Scores[i];
}
}
int main()
{
StudentStat Studobj;
fin.open("EvenC lass.txt");
while(!fin.eof( ))
{
Studobj.Input() ;
}
fin.close();
return 0;
}
Comment