Hi, im working on a project for school and Im having a little trouble. The problem states:
Write a program that reads students names followed by their test scores. The program should output each students name folloed by the test scores and the relevent grade. It should also find and print the highest test score and the name of the students having the highest test score.
Student data should be stored in a struct variable of type studentType which has 4 components for fist and last name, test score and grade. Suppose the class has 20 students. Use an array of 20 components of type studentType
Here is what I have so far.
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
void StuRead(indata, studentType students[]);
char AssignGrade(char LetterGrade, studentType students[]); //here im getting an error: student type has not been declared
void Highest();
void Print(students[]);
struct studentType
{
string fName, lName;
int Scores;
int Tests;
char grade;
};
studentType students[20];
main ()
{
ifstream inFile;
ofstream outFile;
inFile.open("Studinfo.txt");
outFile.open("Stinfo.out");
StuRead(infile, studentType students[]);
return 0;
}
void StuRead(ifstream& indata, studentType students[])
{
int x;
x = 0;
for (x = 1; x < 20; x++)
{
infile >> students[x].lName
>> students[x].fName
>> students[x].Tests;
}
}
char AssignGrade(char LetterGrade, studentType students[])
{
if(score >= 90)
studentType.grade = 'A'; //for these lines im getting this error: expected unqualified-id before '.' token
else if(score >= 80)
studentType.grade = 'B';
else if(score >= 70)
studentType.grade = 'C';
else if(score >= 60)
studentType.grade = 'D';
else
studentType.grade = 'F';
}
void Highest(students[20])
{
int highTest = 0;
for(x = 0; x < 20; x++)
{
if(x > highTest)
highTest = x;
}
}
I just showed a few of the errors but please tear this thing apart and give me any advice u can.
If anyone could help me out a little I would greatly apreciate it :) Thanx alot!