QUOTE(Amadeus @ 28 Aug, 2006 - 11:30 AM)

Can you repost the code?
I sure can, but now, the quiz_avg displays fine. It's the final_grade that still appears wrong in the table. I switched some things back to doubles, not ints, so you will see type double in the code. I fixed the function Calc_Final_Grade so it was just like Calc_Quiz_Avg, but that didn't fix the problem.
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
struct STUDENT_STRUCT
{
char last_name[31];
char first_name[31];
char soc_sec_no[10];
char ph_no[11];
int quiz_1;
int quiz_2;
int quiz_3;
int quiz_4;
int quiz_5;
double quiz_avg;
int final_exam;
int final_grade;
int class_avg;
};
int Load_Student_Table(STUDENT_STRUCT[], int);
void Display_Student_Table(STUDENT_STRUCT[], int);
double Calc_Quiz_Avg(STUDENT_STRUCT[], int);
int Calc_Final_Grade(STUDENT_STRUCT[], int);
int Calc_Class_Avg(int, int);
void Sort_Table(STUDENT_STRUCT[], int);
const int TABLE_SIZE = 25;
int main()
{
STUDENT_STRUCT student_table[TABLE_SIZE];
cout << setprecision(2)
<< setiosflags(ios::fixed)
<< setiosflags(ios::showpoint);
int num_students;
num_students=Load_Student_Table(student_table, TABLE_SIZE);
Calc_Quiz_Avg(student_table, num_students);
// Display the table
cout << endl << endl;
cout << "This is the table you entered: ";
Display_Student_Table(student_table, num_students);
cout << endl << endl;
cin >> num_students;
return 0;
}
int Load_Student_Table(STUDENT_STRUCT student_table[], int num_students)
{
int row=0;
int response=1;
cout << endl;
cout << "Enter the table values as you are prompted:"
<< endl << endl;
while(response==1)
{
cout << endl << endl;
cout << "For row #" << row+1 << " enter:" << endl << endl;
cout << "Last Name: ";
cin.getline(student_table[row].last_name, 31);
cout << "First Name: ";
cin.getline(student_table[row].first_name, 31);
cout << "Social Security Number: ";
cin.getline(student_table[row].soc_sec_no, 10);
cout << "Phone Number: ";
cin.getline(student_table[row].ph_no, 11);
cout << "Quiz 1: ";
cin >> student_table[row].quiz_1;
cout << "Quiz 2: ";
cin >> student_table[row].quiz_2;
cout << "Quiz 3: ";
cin >> student_table[row].quiz_3;
cout << "Quiz 4: ";
cin >> student_table[row].quiz_4;
cout << "Quiz 5: ";
cin >> student_table[row].quiz_5;
cout << "Final Exam: ";
cin >> student_table[row].final_exam;
row++;
cout<<"Do you wish to enter another student? Enter 1 for yes or 0 for no: "<<endl;
cin>>response;
}
return row;
}
double Calc_Quiz_Avg(STUDENT_STRUCT s[], int num_students)
{
const int num_quizzes=5;
int row;
for(row=0; row<num_students; ++row)
s[row].quiz_avg=double(s[row].quiz_1+s[row].quiz_2+s[row].quiz_3+s[row].quiz_4+s[row].quiz_5)/num_quizzes;
return s[row].quiz_avg;
}
int Calc_Final_Grade(STUDENT_STRUCT, int num_students)
{
int row;
int final_exam=0;
double final_grade=0.0;
double quiz_avg=0.0;
const double QUIZ_AVG_WEIGHT=0.75;
const double FINAL_EXAM_WEIGHT=0.25;
for(row=0; row<num_students; ++row)
final_grade=(QUIZ_AVG_WEIGHT*quiz_avg) + (FINAL_EXAM_WEIGHT*final_exam);
return final_grade;
}
int Calc_Class_Avg(STUDENT_STRUCT, int num_students)
{
int final_grade=0;
int total=0;
int class_avg;
class_avg=total+=final_grade/num_students;
return class_avg;
}
void Display_Student_Table(STUDENT_STRUCT student_table[], int num_students)
{
int row;
cout << endl << endl;
cout << setw(14) << left << "Last Name"
<< setw(14) << left << "First Name"
<< setw(14) << left << "Final Exam"
<< setw(14) << left << "Quiz Average"
<< setw(14) << left << "Final Grade" << endl;
for(row=0; row<num_students; ++row)
{
cout << setw(14) << student_table[row].last_name
<< setw(14) << student_table[row].first_name
<< setw(14) << student_table[row].final_exam
<< setw(14) << student_table[row].quiz_avg
<< setw(14) << student_table[row].final_grade << endl;
void Sort_Table(STUDENT_STRUCT student_table[], int num_students);
cout << endl << endl;
cout << "The table sorted alphabetically by last name is:";
void Display_Student_Table(STUDENT_STRUCT student_table[], int num_students);
cout << endl << endl;
cout << setw(14) << left << "Last Name"
<< setw(14) << left << "First Name"
<< setw(14) << left << "Final Exam"
<< setw(14) << left << "Quiz Average"
<< setw(14) << left << "Final Grade" << endl;
for(row=0; row<num_students; ++row);
}
}