this is my code and i don't know what is the issue with it?
#include <fstream> // FILL IN DIRECTIVE FOR FILES
#include <iostream>
#include <iomanip>
using namespace std;
// This program reads records from a file. The file contains the
// following: student's name, two test grades and final exam grade.
// It then prints this information to the screen.
const int NAMESIZE = 15;
const int MAXRECORDS = 50;
struct Grades // declares a structure
{
char name[NAMESIZE + 1];
int test1;
int test2;
int final;
char letter;
};
typedef Grades gradeType[MAXRECORDS];
// This makes gradeType a data type
// that holds MAXRECORDS
// Grades structures.
// FIll IN THE CODE FOR THE PROTOTYPE OF THE FUNCTION ReadIt
// WHERE THE FIRST ARGUMENT IS AN INPUT FILE, THE SECOND IS THE
// ARRAY OF RECORDS, AND THE THIRD WILL HOLD THE NUMBER OF RECORDS
// CURRENTLY IN THE ARRAY.
void readIt(ifstream&, gradeType, int&);
void getGrade(gradeType, int);
int main()
{
ifstream indata;
indata.open("/Users/aziz/Desktop/b/graderoll.dat");
int numRecord; // number of records read in
gradeType studentRecord;
if(!indata)
{
cout << "Error opening file. " << endl;
cout << "It may not exist where indicated" << endl;
return 1;
}
// FILL IN THE CODE TO CALL THE FUNCTION ReadIt.
readIt(indata, studentRecord, numRecord);
// output the information
getGrade(studentRecord, numRecord);
for (int count = 0; count < numRecord; count++)
{
cout << studentRecord[count].name << setw(10)
<< studentRecord[count].test1
<< setw(10) << studentRecord[count].test2;
cout << setw(10) << studentRecord[count].final << endl;
}
return 0;
}
//**************************************************************
// readIt
//
// task: This procedure reads records into an array of
// records from an input file and keeps track of the
// total number of records
// data in: data file containing information to be placed in
// the array
// data out: an array of records and the number of records
//
//**************************************************************
void readIt( ifstream& inData, gradeType gradeRec,int& total) // FILL IN THE CODE FOR THE FORMAL PARAMETERS AND THEIR
// DATA TYPES.
// inData, gradeRec and total are the formal parameters
// total is passed by reference)
{
total = 0;
inData.get(gradeRec[total].name, NAMESIZE);
while (inData)
{
// FILL IN THE CODE TO READ test1
inData >> gradeRec[total].test1;
// FILL IN THE CODE TO READ test2
inData >> gradeRec[total].test2;
// FILL IN THE CODE TO READ final
inData >> gradeRec[total].final;
total++; // add one to total
// FILL IN THE CODE TO CONSUME THE END OF LINE
inData.ignore(80,'\n');
// FILL IN THE CODE TO READ name
inData.get(gradeRec[total].name, NAMESIZE);
}
}
void getGrade(gradeType s,int n)
{
int i;
double a;
for (i = 0; i < n; i++)
{
a=s[i].test1*.3+s[i].final*.4;
if (a >= 90)
s[i].letter ='A';
else if (a >= 80)
s[i].letter ='B';
else if (a >= 70)
s[i].letter ='C';
else if (a >= 60)
s[i].letter ='D';
else
s[i].letter ='F';
}
}
when i run the code the output was:
{\rtf1\ansi\an 0 327671606484879
The output must be like:
Name Income Rent Food Utilities Miscellaneous Net Money Billy Berry
2500.00 700.00 600.00 400.00 500.00 300.00