ok, my brain is fried and i'm frustrated as hell
does anyone have any suggestions at all on how i can fix this mess?
Code:
/*this program computes a final average for marketing students
using structures, pointers, and functions.*/
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <ctype.h>
#define TABLE_SIZE 25
struct STUDENT_STRUCT
{
char last_name [21];
char first_name [21];
char social [20];
char phone [13];
int quiz [5];
int final;
int final_grade;
};
void user_prompt (STUDENT_STRUCT&);
void display_table (STUDENT_STRUCT[], int, double[]);
double& compute_grades (STUDENT_STRUCT&);
int main ()
{
STUDENT_STRUCT main_struct[TABLE_SIZE];
int row = 0;
int count = 1;
char response[8];
cout << "Welcome, Dr. Jacobs, to the marketing\n 101 grade";
cout << "computation program.\n";
cout << "\nEnter first student?\nEnter Y or N\n";
cin.getline(response, 8);
cin.ignore(80, '\n');
while (toupper(*response) == 'Y')
{
for(row=0;row<TABLE_SIZE;++row)
{
while (toupper(*response) == 'Y')
{
user_prompt(main_struct[row]);
cout << "Enter another student?\nEnter Y or N\n\n";
cin.getline(response, 8);
cin.ignore(80, '\n');
}
}
}
main_struct[row].final = *(compute_grades(main_struct[TABLE_SIZE]));
final_grade[row]=
display_table(main_struct[TABLE_SIZE]);
return 0;
}
void user_prompt (STUDENT_STRUCT& stud_struc)
{
int y;
cout << "\nEnter student's last name: ";
cin.getline (stud_struc.last_name, 21);
cin.ignore (80, '\n');
cout << "\nEnter student's first name: ";
cin.getline (stud_struc.first_name, 21);
cin.ignore (80, '\n');
cout << "\nEnter student's social security number: ";
cin.getline (stud_struc.social, 20);
cin.ignore (80, '\n');
cout << "\nEnter student's phone number: ";
cin.getline (stud_struc.phone, 13);
cin.ignore (80, '\n');
for (y=0;y<5;++y)
{
cout << "\nEnter student's grade for quiz " << y+1 << ": ";
cin >> stud_struc.quiz[y];
}
cout << "\nEnter the student's final exam grade: ";
cin >> stud_struc.final;
}
void display_table (STUDENT_STRUCT stud_struc[],int size, double quiz[])
{
int row;
cout << "\n\n" << setw(13) << "Last Name"
<< setw(13) << "First Name"
<< setw(13) << "Quiz Average"
<< setw(13) << "Final Exam"
<< setw(13) << "Final Grade";
for (row=0;row<TABLE_SIZE;++row)
cout << "\n" << setw(13) << stud_struc[row].last_name
<< setw(13) << stud_struc[row].first_name
<< setw(13) << quiz[row]
<< setw(13) << stud_struc[row].final
<< setw(13) << stud_struc[row].final_grade;
}
double& compute_grades (STUDENT_STRUCT& stud_table)
{
int row,
q;
double quiz_total[TABLE_SIZE],
quiz_average[TABLE_SIZE],
grade[TABLE_SIZE];
for (row=0;row<TABLE_SIZE;++row)
{
for (q=0;q<5;++q)
{
quiz_total[row] += stud_table[row].quiz[q];
}
}
for (row=0;row<TABLE_SIZE;++row)
{
quiz_average[row] = quiz_total[row]/5;
grade[row] = ((.75 * quiz_average[row]) + (.25 * stud_table[row].final[row]));
}
return &grade;
}