Average Student Grade HW (Please Help ASAP)

Hello guys,

I have a homework assignment due tomorrow. I put my code below but I have several errors which I can't seem to figure out why :(. The assignment is below and below that is my current code. It is due tomorrow so I would GREATLY if someone can help me ASAP

"An Instructor needs a computer program that can compute course-grades for his classes. When the program runs, it should request last name, two test grades and one homework grade for each student at a time. IT should then compute the course-grade by using the following formula: Course-grade = 60% of average of tests + 40% of homework grade.
There are 5 last names and 3 grades for each student. It should be rounded to the nearest integer. Then print the name of the student, course grade as a ninteger number next to it, and a course grade in letter form next to that. Letter grade is determined by the following formula:
90+ - A
80-89= B
70-79= C
60-69= D
Below 60= F
Class size is unknown. Therefore, you need to use a sentinel-controlled loop to repeat this process as long as there is more data.
My code is below folks. Please help me I can't figure out why it isnt running

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include <iostream>
#include <cmath>
#include <string>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
	struct SStudent{
string name;
double hwAve;
double testAve;
double finalScore;
char grade;
double tests[2];
double homework[1];
double part;
} stu[3];
int getInput ( SStudent [], int);       
void process ( SStudent [], int );
void display ( const SStudent [], int );
int main()
{int n;
n=getInput ( stu,3 );
if(n<0)
   return 1;
process ( stu,n );
display(stu,n);

system("pause");
return 0;
}


int getInput ( SStudent stu[], intn)        
{ifstream in;
int i,m=0;
string last,first;

in>>first;
while(in)
{in>>last;
stu[m].name=first+" "+last;
for(i=0;i<2;i++)
       in>>stu[m].tests[i];
   for(i=0;i<3;i++)
      in>>stu[m].homework[i];
   stu[m].part=100;
   m++;
   in>>first;
   }
in.close();
return m;
}

void process ( SStudent stu[], intn)         // send numberof students really stored in the array
                                          // calculate hwAve, testAve, finalScore, and grade
                                         // for each student on the array
{int i,j;
double maxpoints[3]={25,30,40,50,35,35,50};
char grades[6]={'F','D','C','B','A','A'};
double tot;
for(i=0;i<n;i++)
   {
  stu[i].testAve=(stu[i].tests[0]+stu[i].tests[1])/2.;
    tot=0;
   for(j=0;j<3;j++)
     tot+=stu[i].homework[j]/maxpoints[j]*100.;
    stu[i].hwAve=tot/3.;
  stu[i].finalScore=stu[i].testAve*.6+stu[i].hwAve*.3+stu[i].part*.1;
   j=stu[i].finalScore/3.-9;
   if(j<0)
       j=0;
   stu[i].grade=grades[j];
   }
     
}
void display ( const SStudent stu[], int n) // send number ofstudents really stored in array
                                       // do grade analysis and display result
                                       // open output file should be done in the function
{int i,a=0,b=0,c=0,d=0,f=0;
ofstream out;
out.open( "prg7out.txt");
out<<fixed<<showpoint<<setprecision(1);   
out<<"STUDENTID           HWAVE   TEST AVE     FINALSCORE         GRADE\n";
for(i=0;i<n;i++)
    {
   out<<setw(15)<<left<<stu[i].name<<setw(13)<<right<<stu[i].hwAve<<setw(15);
    out<<stu[i].testAve<<setw(20)<<stu[i].finalScore<<setw(22)<<stu[i].grade<<endl;
  
     if(stu[i].grade=='A')
          a++;
     else if(stu[i].grade=='B')
          b++;
      else if(stu[i].grade=='C')
          c++;
      else if(stu[i].grade=='D')
          d++;
      else f++;    
    }
out<<endl;
out<<"Number of A's: "<<a<<endl;

out<<"Number of B's: "<<b<<endl;

out<<"Number of C's: "<<c<<endl;

out<<"Number of D's: "<<d<<endl;

out<<"Number of F's: "<<f<<endl;
out.close();
}
	return 0;
}
Would be helpful if you posted the errors you have.

You should pick a format to follow, your code is very hard to read as it currently is. https://en.wikipedia.org/wiki/Indent_style

You can't have two main functions.
You shouldn't be defining a struct in a function in this case.
2 errors now - line 28 col 2 C:\Users\Rob\Desktop\main.cpp [Error] expected declaration before '}' token
Other error line 28- "Recipe target for main.o failed"

Please help me ASAP guys this is due at 2PM EST


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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <iostream>
#include <cmath>
#include <string>

//Robert Gillooly
//CSCI 272-02

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
        
string name;
char lastname;
double hwAve;
double testAve;
double finalScore;
int grade;
double tests[2];
double homework[1];
double part;
} int grade[3];
char getInput ( char Lastname [], char);       
void process ( char Lastname [], char );
void display ( char Lastname [], char );

	
	
	}
	int n;
n=getInput ( stu,3 );
if(n<0)
   return 1;
process ( stu,n );
display(stu,n);

while (cin.get() != '\n');

}


char getInput ( char Lastname stu[], char)        
{ifstream in;
int i,m=0;
string last,first;

in>>first;
while(in)
{in>>last;
stu[m].name=first+" "+last;
for(i=0;i<2;i++)
       in>>stu[m].tests[i];
   for(i=0;i<3;i++)
      in>>stu[m].homework[i];
   stu[m].part=100;
   m++;
   in>>first;
   }
   
   
in.close();
return m;
}

void process ( SStudent stu[], intn)         // send numberof students really stored in the array
                                          // calculate hwAve, testAve, finalScore, and grade
                                         // for each student on the array
{int i,j;
double maxpoints[3]={25,30,40,50,35,35,50};
char grades[6]={'F','D','C','B','A','A'};
double tot;
for(i=0;i<n;i++)
   {
  stu[i].testAve=(stu[i].tests[0]+stu[i].tests[1])/2.;
    tot=0;
   for(j=0;j<3;j++)
     tot+=stu[i].homework[j]/maxpoints[j]*100.;
    stu[i].hwAve=tot/3.;
  stu[i].finalScore=stu[i].testAve*.6+stu[i].hwAve*.3+stu[i].part*.1;
   j=stu[i].finalScore/3.-9;
   if(j<0)
       j=0;
   stu[i].grade=grades[j];
   }
     
}
void display ( const SStudent stu[], int n) // send number ofstudents really stored in array
                                       // do grade analysis and display result
                                       // open output file should be done in the function
{int i,a=0,b=0,c=0,d=0,f=0;

out<<fixed<<showpoint<<setprecision(1);   
out<<"STUDENTID           HWAVE   TEST AVE     FINALSCORE         GRADE\n";
for(i=0;i<n;i++)
    {
   out<<setw(15)<<left<<stu[i].name<<setw(13)<<right<<stu[i].hwAve<<setw(15);
    out<<stu[i].testAve<<setw(20)<<stu[i].finalScore<<setw(22)<<stu[i].grade<<endl;
  
     if(stu[i].grade=='A')
          a++;
     else if(stu[i].grade=='B')
          b++;
      else if(stu[i].grade=='C')
          c++;
      else if(stu[i].grade=='D')
          d++;
      else f++;    
    }
out<<endl;
out<<"Number of A's: "<<a<<endl;

out<<"Number of B's: "<<b<<endl;

out<<"Number of C's: "<<c<<endl;

out<<"Number of D's: "<<d<<endl;

out<<"Number of F's: "<<f<<endl;
out.close();
}
system("Pause");
        return 0;
}


2 errors now -
Topic archived. No new replies allowed.