OK, so i need help adding my total_points = temp1 + temp2 + temp3, but everytime they just equal 0. This is a student grade class average program, where you enter a student's info, it gets calculated, then you add the next, after entering all studen't you have to figure out the class average which i am having a hard time doing

Thanks in advance,

24 man hours to one simple program can take its toll on a person.

//Marc Capul
//10/18/09
//10/18/09
//CISC 192 C/C++ Programming
//Prof. Johnson
//Assignment 3
// WEEK 9

#include <iostream>
using namespace std;

int n=0;
double total_points;
int temp_1, temp_2, temp_3;
struct student
       { 
       string name_first, name_last;
       char letter_grade;
       double student_num, quiz_1, quiz_2, mid_exam, final_exam, total_points,;
       double percent_total, class_total, class_avg;
       };
void get_data(student& record);
void calc_grade(student& record);
void show_results(student& record);
void class_avg();
 
int main()
{
    char ans;
    student  record, record1, record2, record3;
    {
         n++;
         get_data(record1);
         calc_grade(record1);
         record.total_points = temp1;
         show_results(record1);
         cout << temp1;
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
        while (ans == 'y' || ans == 'Y');
    {
         n++;
         get_data(record2);
         calc_grade(record2);
         record.total_points = temp2;
         show_results(record2);
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
        while (ans == 'y' || ans == 'Y');
    {
         n++;
         get_data(record3);
         calc_grade(record3);
         record.total_points = temp3;
         show_results(record3);
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
         class_avg();
         system("PAUSE");
          return 0;
} 

void get_data(student& record)
{
     cout << "Please enter the following:\n";
     cout << "Student ID number:";
     cin >> record.student_num;
            while (record.student_num < 1 || record.student_num > 99999)
                   {
                         cout << "Invalid Student ID number.\n";
                         cout << "Please enter again.\n";
                         cin >> record.student_num;
                         }
     cout << "First name:";
     cin >> record.name_first;
     cout << "Last name:";
     cin >> record.name_last;
     cout << "Quiz #1 score:";
     cin >> record.quiz_1;
         while (record.quiz_1 < 0 || record.quiz_1 > 25)
                   {
                         cout << "Invalid quiz score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.quiz_1;
                         }
     cout << "Quiz #2 Score:";
     cin >> record.quiz_2;
         while (record.quiz_2 < 0 || record.quiz_2 > 25)
                   {
                         cout << "Invalid quiz score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.quiz_2;
                         }
     cout << "Midterm exam score:";
     cin >> record.mid_exam;
         while (record.mid_exam < 0 || record.mid_exam > 50)
                   {
                         cout << "Invalid exam score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.mid_exam;
                         }
     cout << "Final exam score:";
     cin >> record.final_exam;
         while (record.final_exam < 0 || record.final_exam > 100)
                   {
                         cout << "Invalid exam score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.final_exam;
                         }
     }

void calc_grade(student& record)
     {
      char letter_grade;
      record.total_points = (record.quiz_1 + record.quiz_2 + record.mid_exam + record.final_exam);
      
      
      record.percent_total = (100)*(record.total_points/200);
      
      
      if (record.percent_total >= 90)
         {
          record.letter_grade = 'A';
          }
      else if (record.percent_total >= 80 && record.percent_total < 90)
           { 
            record.letter_grade = 'B';
            }
      else if (record.percent_total >= 70 && record.percent_total < 80)
           {
            record.letter_grade = 'C';
            }
      else if (record.percent_total >= 60 && record.percent_total < 70)
           {
            record.letter_grade = 'D';
            }
      else 
           {
            record.letter_grade = 'F';
                        }
            }

           

void show_results(student& record)
     {
      cout << "Summary:" << endl;
      cout << "ID number:";
      cout << record.student_num << endl;
      cout << "Name:";
      cout << record.name_first <<" "<< record.name_last << endl;
      cout << "Quiz #1 score:";
      cout << record.quiz_1 << endl;
      cout << "Quiz #2 score:";
      cout << record.quiz_2 << endl;
      cout << "Midterm exam score:";
      cout << record.mid_exam << endl;
      cout << "Final exam score:";
      cout << record.final_exam << endl;
      cout << "Total points earned:";
      cout << record.total_points << endl;
      cout << "Percent Total:";
      cout << record.percent_total << "%" << endl;
      cout << "Grade:";
      cout << record.letter_grade << endl;
      }

void class_avg()
     {
      double avg_points, avg_percent;
      char letter_grade;
      cout << endl;
      cout << "Number of students processed:" << n << endl;
      cout << temp1 << endl << temp2 << temp3 << endl;
      cout << total_points << endl;
      total_points = temp1 + temp2 + temp3;
      avg_points = total_points/n;
      
      if (avg_percent >= 90)
         {
          letter_grade = 'A';
          
          }
      else if (avg_percent >= 80 && avg_percent < 90)
           { 
            letter_grade = 'B';
            }
      else if (avg_percent >= 70 && avg_percent < 80)
           {
            letter_grade = 'C';
            }
      else if (avg_percent >= 60 && avg_percent < 70)
           {
            letter_grade = 'D';
            }
      else 
           {
            letter_grade = 'F';
                        }

      cout << "Average total points achieved: " << avg_points << endl;
      cout << "Average letter grade: " << letter_grade;
}

Recommended Answers

All 10 Replies

Wouldn't it be helpful to us that aren't psychic to actually explain the problem? I assume you are having trouble compiling.

you are assigning your temps TO the record.totalpoints when the temps haven't been assigned any value.

also, your temp1,temp2,temp3 are not in scope with the class_avg function. pass them in as arguments. you should only need one while loop, if there is just a set number of records, use a for loop.

it's easy to get overwhelmed, but just take a step back and sketch it out on a piece of paper

i just had a glance at your code
you declared

int temp_1, temp_2, temp_3;

and used

record.total_points = temp1;
record.total_points = temp2;
record.total_points = temp3;

mismatch in variable names

you must be getting compilation errors.
correct the names first, and you are not updating the global variables how will the changes be effected
.

OK so i added temp1, temp2, temp 3 as arguments to the class_avg() function but it is still not working.

I think its because im still not assigning values to temp_1 temp_2 and temp_3.

Any ideas?

Thanks again

//Marc Capul
//10/14/09
//10/14/09
//CISC 192 C/C++ Programming
//Prof. Johnson
//Assignment 3
// WEEK 9

#include <iostream>
using namespace std;

int n=0;
double total_points;
int temp_1, temp_2, temp_3;
struct student
       { 
       string name_first, name_last;
       char letter_grade;
       double student_num, quiz_1, quiz_2, mid_exam, final_exam, total_points,;
       double percent_total, class_total, class_avg;
       };
void get_data(student& record);
void calc_grade(student& record);
void show_results(student& record);
double class_avg(int temp1, int temp2, int temp3);
 
int main()
{
    char ans;
    student  record, record1, record2, record3;
    {
         n++;
         get_data(record1);
         record.total_points = temp_1;
         calc_grade(record1);
         show_results(record1);
         cout << temp_1;
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
        while (ans == 'y' || ans == 'Y');
    {
         n++;
         get_data(record2);
         record.total_points = temp_2;
         calc_grade(record2);
         show_results(record2);
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
        while (ans == 'y' || ans == 'Y');
    {
         n++;
         get_data(record3);
         record.total_points = temp_3;
         calc_grade(record3);
         show_results(record3);
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
         class_avg(temp_1, temp_2, temp_3);
         system("PAUSE");
          return 0;
} 

void get_data(student& record)
{
     cout << "Please enter the following:\n";
     cout << "Student ID number:";
     cin >> record.student_num;
            while (record.student_num < 1 || record.student_num > 99999)
                   {
                         cout << "Invalid Student ID number.\n";
                         cout << "Please enter again.\n";
                         cin >> record.student_num;
                         }
     cout << "First name:";
     cin >> record.name_first;
     cout << "Last name:";
     cin >> record.name_last;
     cout << "Quiz #1 score:";
     cin >> record.quiz_1;
         while (record.quiz_1 < 0 || record.quiz_1 > 25)
                   {
                         cout << "Invalid quiz score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.quiz_1;
                         }
     cout << "Quiz #2 Score:";
     cin >> record.quiz_2;
         while (record.quiz_2 < 0 || record.quiz_2 > 25)
                   {
                         cout << "Invalid quiz score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.quiz_2;
                         }
     cout << "Midterm exam score:";
     cin >> record.mid_exam;
         while (record.mid_exam < 0 || record.mid_exam > 50)
                   {
                         cout << "Invalid exam score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.mid_exam;
                         }
     cout << "Final exam score:";
     cin >> record.final_exam;
         while (record.final_exam < 0 || record.final_exam > 100)
                   {
                         cout << "Invalid exam score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.final_exam;
                         }
     }

void calc_grade(student& record)
     {
      char letter_grade;
      record.total_points = (record.quiz_1 + record.quiz_2 + record.mid_exam + record.final_exam);
      
      
      record.percent_total = (100)*(record.total_points/200);
      
      
      if (record.percent_total >= 90)
         {
          record.letter_grade = 'A';
          }
      else if (record.percent_total >= 80 && record.percent_total < 90)
           { 
            record.letter_grade = 'B';
            }
      else if (record.percent_total >= 70 && record.percent_total < 80)
           {
            record.letter_grade = 'C';
            }
      else if (record.percent_total >= 60 && record.percent_total < 70)
           {
            record.letter_grade = 'D';
            }
      else 
           {
            record.letter_grade = 'F';
                        }
            }

           

void show_results(student& record)
     {
      cout << "Summary:" << endl;
      cout << "ID number:";
      cout << record.student_num << endl;
      cout << "Name:";
      cout << record.name_first <<" "<< record.name_last << endl;
      cout << "Quiz #1 score:";
      cout << record.quiz_1 << endl;
      cout << "Quiz #2 score:";
      cout << record.quiz_2 << endl;
      cout << "Midterm exam score:";
      cout << record.mid_exam << endl;
      cout << "Final exam score:";
      cout << record.final_exam << endl;
      cout << "Total points earned:";
      cout << record.total_points << endl;
      cout << "Percent Total:";
      cout << record.percent_total << "%" << endl;
      cout << "Grade:";
      cout << record.letter_grade << endl;
      }

double class_avg(int temp1, int temp2, int temp3)
     {
      double avg_points, avg_percent;
      char letter_grade;
      cout << endl;
      cout << "Number of students processed:" << n << endl;
      cout << temp1 << endl << temp2 << temp3 << endl;
      total_points = temp1 + temp2 + temp3;
      cout << total_points << endl;
      avg_points = total_points/n;
      
      if (avg_percent >= 90)
         {
          letter_grade = 'A';
          
          }
      else if (avg_percent >= 80 && avg_percent < 90)
           { 
            letter_grade = 'B';
            }
      else if (avg_percent >= 70 && avg_percent < 80)
           {
            letter_grade = 'C';
            }
      else if (avg_percent >= 60 && avg_percent < 70)
           {
            letter_grade = 'D';
            }
      else 
           {
            letter_grade = 'F';
            }

      cout << "Average total points achieved: " << avg_points << endl;
      cout << "Average letter grade: " << letter_grade;
}

First things first: Dont use system("Pause") it has been discussed to death here and everywhere on the web.

Second: The next problem is that you are using temp1 without initializing it. i.e every time you run the program it could start with a different value and you don't know what it is.

Third: you use a struct student, BUT by not having a constructor in this object all the variables DO NOT GET INITIALIZED. Therefore your have another problem.

Four: You really really need an array of students. it would make the code MUCH shorter.

Five : Semi colon after the while (ans=='y' || ans=='Y') ;
is wrong. because then the while does nothing, or loops indefinitely

Six: the reason that your class_ave does not work is that your pass three uninitialized variables. Then you have the logic wrong. Ok. Consider that you wish to pass up to three students, then temp_1 etc
should be the three values the students get.
You might chose to do that like this

// THIS IS IN YOUR MAIN:
class_ave(record1.total,record2.total,record2.total);

Note, the thing that is getting you mixed up is that the values or VARIABLES that you use to call the function are not the same names as are in the declaration of the function, you can equally call the function like this
class_ave(40,45,34);

Note that you have then made another error. Your values in are int. This is not correct, since you are taking an average percentage on four tests and that can be 45.5 or a non-iteger number

Finally you are then forgetting what happens to the average when you enter only one student, you must NOT use the second and third values because they are meaningless.

Sorry that was a bit long, but your HAVE to go through this on paper.
It will really really help to write out a piece of paper with all the variable names and their values. If you don't give it one to start assume something very big or very negative and see what you get.

As you get better, you can then do that with the debugger, and finally, you will be able to read the code. Interestingly once you get to that stage, it seems that you can easily do that for almost any other language that you learn, I don't know why or how..

Best of luck..

ok i tried to fix going by what you said and still nothing. also we cant use arrays because we haven't learned about them yet.

//Marc Capul
//10/14/09
//10/14/09
//CISC 192 C/C++ Programming
//Prof. Johnson
//Assignment 3
// WEEK 9

#include <iostream>
using namespace std;

int n=0;
double total_points;
int temp_1, temp_2, temp_3;
struct student
       { 
       string name_first, name_last;
       char letter_grade;
       double student_num, quiz_1, quiz_2, mid_exam, final_exam, total_points,;
       double percent_total, class_total, class_avg;
       };
void get_data(student& record);
void calc_grade(student& record);
void show_results(student& record);
void class_avg(student& record, record1, record2, record3);
 
int main()
{
    char ans;
    student  record, record1, record2, record3;
    {
         n++;
         get_data(record1);
         record.total_points = record1.total_points;
         calc_grade(record1);
         show_results(record1);
         cout << temp_1;
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
        while (ans == 'y' || ans == 'Y')
    {
         n++;
         get_data(record2);
         record.total_points = record2.total_points;
         calc_grade(record2);
         show_results(record2);
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
        while (ans == 'y' || ans == 'Y')
    {
         n++;
         get_data(record3);
         record.total_points = record3.total_points;
         calc_grade(record3);
         show_results(record3);
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
         class_avg(record, record1.total_points, record2.total_points, record3.total_points);
         system("PAUSE");
          return 0;
} 

void get_data(student& record)
{
     cout << "Please enter the following:\n";
     cout << "Student ID number:";
     cin >> record.student_num;
            while (record.student_num < 1 || record.student_num > 99999)
                   {
                         cout << "Invalid Student ID number.\n";
                         cout << "Please enter again.\n";
                         cin >> record.student_num;
                         }
     cout << "First name:";
     cin >> record.name_first;
     cout << "Last name:";
     cin >> record.name_last;
     cout << "Quiz #1 score:";
     cin >> record.quiz_1;
         while (record.quiz_1 < 0 || record.quiz_1 > 25)
                   {
                         cout << "Invalid quiz score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.quiz_1;
                         }
     cout << "Quiz #2 Score:";
     cin >> record.quiz_2;
         while (record.quiz_2 < 0 || record.quiz_2 > 25)
                   {
                         cout << "Invalid quiz score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.quiz_2;
                         }
     cout << "Midterm exam score:";
     cin >> record.mid_exam;
         while (record.mid_exam < 0 || record.mid_exam > 50)
                   {
                         cout << "Invalid exam score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.mid_exam;
                         }
     cout << "Final exam score:";
     cin >> record.final_exam;
         while (record.final_exam < 0 || record.final_exam > 100)
                   {
                         cout << "Invalid exam score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.final_exam;
                         }
     }

void calc_grade(student& record)
     {
      char letter_grade;
      record.total_points = (record.quiz_1 + record.quiz_2 + record.mid_exam + record.final_exam);
      
      
      record.percent_total = (100)*(record.total_points/200);
      
      
      if (record.percent_total >= 90)
         {
          record.letter_grade = 'A';
          }
      else if (record.percent_total >= 80 && record.percent_total < 90)
           { 
            record.letter_grade = 'B';
            }
      else if (record.percent_total >= 70 && record.percent_total < 80)
           {
            record.letter_grade = 'C';
            }
      else if (record.percent_total >= 60 && record.percent_total < 70)
           {
            record.letter_grade = 'D';
            }
      else 
           {
            record.letter_grade = 'F';
                        }
            }

           

void show_results(student& record)
     {
      cout << "Summary:" << endl;
      cout << "ID number:";
      cout << record.student_num << endl;
      cout << "Name:";
      cout << record.name_first <<" "<< record.name_last << endl;
      cout << "Quiz #1 score:";
      cout << record.quiz_1 << endl;
      cout << "Quiz #2 score:";
      cout << record.quiz_2 << endl;
      cout << "Midterm exam score:";
      cout << record.mid_exam << endl;
      cout << "Final exam score:";
      cout << record.final_exam << endl;
      cout << "Total points earned:";
      cout << record.total_points << endl;
      cout << "Percent Total:";
      cout << record.percent_total << "%" << endl;
      cout << "Grade:";
      cout << record.letter_grade << endl;
      }

void class_avg(student& record, record1, record2, record3)
     {
      double avg_points, avg_percent;
      char letter_grade;
      cout << endl;
      cout << "Number of students processed:" << n << endl;
      cout << temp1 << endl << temp2 << temp3 << endl;
      total_points = temp1 + temp2 + temp3;
      cout << total_points << endl;
      avg_points = total_points/n;
      cout << "Average total points:" << avg_points;
      avg_percent = avg_points/200;
      
      if (avg_percent >= 90)
         {
          letter_grade = 'A';
          
          }
      else if (avg_percent >= 80 && avg_percent < 90)
           { 
            letter_grade = 'B';
            }
      else if (avg_percent >= 70 && avg_percent < 80)
           {
            letter_grade = 'C';
            }
      else if (avg_percent >= 60 && avg_percent < 70)
           {
            letter_grade = 'D';
            }
      else 
           {
            letter_grade = 'F';
            }

      cout << "Average total points achieved: " << avg_points << endl;
      cout << "Average letter grade: " << letter_grade;
}

edit delete

scratch that last post. ok i changed it a little but this time it is giving me weird numbers for low score and average total points. ive also made it display the total_points for each student but still they give the wrong values except for student 2.

//Marc Capul
//10/14/09
//10/14/09
//CISC 192 C/C++ Programming
//Prof. Johnson
//Assignment 3
// WEEK 9

#include <iostream>
using namespace std;

int n=0;
int temp_1, temp_2, temp_3, avg;
struct student
       { 
       string name_first, name_last;
       char letter_grade;
       double student_num, quiz_1, quiz_2, mid_exam, final_exam;
       int total_points,;
       double percent_total, class_total, class_avg;
       };

void get_data(student&);
void calc_grade(student& record);
void show_results(student& record);
void class_avg(int i, int temp1, int temp2, int temp3);

 
int main()
{
    char ans;
    student  record, record1, record2, record3;
    {
         n++;
         get_data(record1);
         temp_1 = record1.total_points;
         calc_grade(record1);
         show_results(record1);
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
        while (ans == 'y' || ans == 'Y')
    {
         n++;
         get_data(record2);
         temp_2 = record2.total_points;
         calc_grade(record2);
         show_results(record2);
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
        while (ans == 'y' || ans == 'Y')
    {
         n++;
         get_data(record3);
         temp_3 = record3.total_points;
         calc_grade(record3);
         show_results(record3);
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
         class_avg(n, temp_1, temp_2, temp_3);
         system("PAUSE");
          return 0;
} 

void get_data(student& record)
{
     cout << "Please enter the following:\n";
     cout << "Student ID number:";
     cin >> record.student_num;
            while (record.student_num < 1 || record.student_num > 99999)
                   {
                         cout << "Invalid Student ID number.\n";
                         cout << "Please enter again.\n";
                         cin >> record.student_num;
                         }
     cout << "First name:";
     cin >> record.name_first;
     cout << "Last name:";
     cin >> record.name_last;
     cout << "Quiz #1 score:";
     cin >> record.quiz_1;
         while (record.quiz_1 < 0 || record.quiz_1 > 25)
                   {
                         cout << "Invalid quiz score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.quiz_1;
                         }
     cout << "Quiz #2 Score:";
     cin >> record.quiz_2;
         while (record.quiz_2 < 0 || record.quiz_2 > 25)
                   {
                         cout << "Invalid quiz score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.quiz_2;
                         }
     cout << "Midterm exam score:";
     cin >> record.mid_exam;
         while (record.mid_exam < 0 || record.mid_exam > 50)
                   {
                         cout << "Invalid exam score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.mid_exam;
                         }
     cout << "Final exam score:";
     cin >> record.final_exam;
         while (record.final_exam < 0 || record.final_exam > 100)
                   {
                         cout << "Invalid exam score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.final_exam;
                         }
     }

void calc_grade(student& record)
     {
      char letter_grade;
      record.total_points = (record.quiz_1 + record.quiz_2 + record.mid_exam + record.final_exam);
      
      
      record.percent_total = (100)*(record.total_points/200);
      
      
      if (record.percent_total >= 90)
         {
          record.letter_grade = 'A';
          }
      else if (record.percent_total >= 80 && record.percent_total < 90)
           { 
            record.letter_grade = 'B';
            }
      else if (record.percent_total >= 70 && record.percent_total < 80)
           {
            record.letter_grade = 'C';
            }
      else if (record.percent_total >= 60 && record.percent_total < 70)
           {
            record.letter_grade = 'D';
            }
      else 
           {
            record.letter_grade = 'F';
                        }
            }

           

void show_results(student& record)
     {
      cout << "Summary:" << endl;
      cout << "ID number:";
      cout << record.student_num << endl;
      cout << "Name:";
      cout << record.name_first <<" "<< record.name_last << endl;
      cout << "Quiz #1 score:";
      cout << record.quiz_1 << endl;
      cout << "Quiz #2 score:";
      cout << record.quiz_2 << endl;
      cout << "Midterm exam score:";
      cout << record.mid_exam << endl;
      cout << "Final exam score:";
      cout << record.final_exam << endl;
      cout << "Total points earned:";
      cout << record.total_points << endl;
      cout << "Percent Total:";
      cout << record.percent_total << "%" << endl;
      cout << "Grade:";
      cout << record.letter_grade << endl;
      }

void class_avg(int i, int temp1, int temp2, int temp3)
{
   char avg_grade; 
   double avg_percent; 
   int highest;
   int lowest;
   int avg_score;
   avg_score = (temp1 + temp2 + temp3)/3;
   avg_percent = ((temp1 + temp2 + temp3)/6);
   
   
   cout << "Number of students processed: " << i << "\n";
   
   
   if (temp1 > temp2 && temp1 > temp3)
   {
      highest = temp1;      
      cout << "Highest total points achieved: " << highest << "\n";
   }
   else if (temp2 > temp1 && temp2 > temp3)
   {
        highest = temp2;
        cout << "Highest total points achieved: " << highest << "\n";
   }  
   else if (temp3 > temp1 && temp3 > temp2)
   {
        highest = temp3;
        cout << "Highest total points achieved: " << highest << "\n";
   }
   
   
   if (avg_percent >=90)
   {
             avg_grade = 'A';
   }
   else if (avg_percent >= 80 && avg_percent < 90)
         {
             avg_grade = 'B';
         }
   else if (avg_percent >= 70 && avg_percent < 80)
         {
             avg_grade = 'C';
         }
   else if (avg_percent >= 60 && avg_percent < 70)
         {
             avg_grade = 'D';
         }
   else 
             avg_grade = 'F';
  
       

   if (temp1 < temp2 && temp1 < temp3)
   {
      lowest = temp1;      
      cout << "Lowest total points achieved: " << lowest << "\n";
   }
   else if (temp2 < temp1 && temp2 < temp3)
   {
        lowest = temp2;
        cout << "Lowest total points achieved: " << lowest << "\n";
   }  
   else if (temp3 < temp1 && temp3 < temp2)
   {
        lowest = temp3;
        cout << "Lowest total points achieved: " << lowest << "\n";
   }

   cout << "Average total points achieved: " << avg_score << "\n";
   cout << "Average letter grade achieved: " << avg_grade << "\n";
   cout << temp1 << endl << temp2 << endl << temp3;
}

OK I almost got it!
The only problem is that my student total score 3 shows up as zero.

//Marc Capul
//10/14/09
//10/14/09
//CISC 192 C/C++ Programming
//Prof. Johnson
//Assignment 3
// WEEK 9

#include <iostream>
using namespace std;

int n=0;
double temp_1, temp_2, temp_3, avg;
struct student
       { 
       string name_first, name_last;
       char letter_grade;
       double student_num, quiz_1, quiz_2, mid_exam, final_exam;
       double total_points;
       double percent_total, class_total, class_avg;
       };

void get_data(student&);
void calc_grade(student& record);
void show_results(student& record);
void class_avg(int i, double temp1, double temp2, double temp3);

 
int main()
{
    char ans;
    student record1, record2, record3;
    {
         n++;
         get_data(record1);
         temp_1 = record1.total_points;
         calc_grade(record1);
         show_results(record1);
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
        while (ans == 'y' || ans == 'Y')
    {
         n++;
         get_data(record2);
         temp_2 = record2.total_points;
         calc_grade(record2);
         show_results(record2);
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
        while (ans == 'y' || ans == 'Y')
    {
         n++;
         get_data(record3);
         temp_3 = record3.total_points;
         calc_grade(record3);
         show_results(record3);
         cout << "Is there another student's scores that need to be processed?";
         cout << endl;
         cout << "Press 'y' or 'Y' for yes or 'n' for Class Summary.";
         cin >> ans;
         }
         class_avg(n, temp_1, temp_2, temp_3);
         system("PAUSE");
          return 0;
} 

void get_data(student& record)
{
     cout << "Please enter the following:\n";
     cout << "Student ID number:";
     cin >> record.student_num;
            while (record.student_num < 1 || record.student_num > 99999)
                   {
                         cout << "Invalid Student ID number.\n";
                         cout << "Please enter again.\n";
                         cin >> record.student_num;
                         }
     cout << "First name:";
     cin >> record.name_first;
     cout << "Last name:";
     cin >> record.name_last;
     cout << "Quiz #1 score:";
     cin >> record.quiz_1;
         while (record.quiz_1 < 0 || record.quiz_1 > 25)
                   {
                         cout << "Invalid quiz score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.quiz_1;
                         }
     cout << "Quiz #2 Score:";
     cin >> record.quiz_2;
         while (record.quiz_2 < 0 || record.quiz_2 > 25)
                   {
                         cout << "Invalid quiz score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.quiz_2;
                         }
     cout << "Midterm exam score:";
     cin >> record.mid_exam;
         while (record.mid_exam < 0 || record.mid_exam > 50)
                   {
                         cout << "Invalid exam score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.mid_exam;
                         }
     cout << "Final exam score:";
     cin >> record.final_exam;
         while (record.final_exam < 0 || record.final_exam > 100)
                   {
                         cout << "Invalid exam score.\n";
                         cout << "Please enter again.\n";
                         cin >> record.final_exam;
                         }
      record.total_points = (record.quiz_1 + record.quiz_2 + record.mid_exam + record.final_exam);
     }

void calc_grade(student& record)
     {
      char letter_grade;
      record.total_points = (record.quiz_1 + record.quiz_2 + record.mid_exam + record.final_exam);
      
      
      record.percent_total = (100)*((record.quiz_1 + record.quiz_2 + record.mid_exam + record.final_exam)/200);
      
      
      if (record.percent_total >= 90)
         {
          record.letter_grade = 'A';
          }
      else if (record.percent_total >= 80 && record.percent_total < 90)
           { 
            record.letter_grade = 'B';
            }
      else if (record.percent_total >= 70 && record.percent_total < 80)
           {
            record.letter_grade = 'C';
            }
      else if (record.percent_total >= 60 && record.percent_total < 70)
           {
            record.letter_grade = 'D';
            }
      else 
           {
            record.letter_grade = 'F';
                        }
            }

           

void show_results(student& record)
     {
      cout << "Summary:" << endl;
      cout << "ID number:";
      cout << record.student_num << endl;
      cout << "Name:";
      cout << record.name_first <<" "<< record.name_last << endl;
      cout << "Quiz #1 score:";
      cout << record.quiz_1 << endl;
      cout << "Quiz #2 score:";
      cout << record.quiz_2 << endl;
      cout << "Midterm exam score:";
      cout << record.mid_exam << endl;
      cout << "Final exam score:";
      cout << record.final_exam << endl;
      cout << "Total points earned:";
      cout << record.total_points << endl;
      cout << "Percent Total:";
      cout << record.percent_total << "%" << endl;
      cout << "Grade:";
      cout << record.letter_grade << endl;
      }

void class_avg(int i, double temp1, double temp2, double temp3)
{
   char avg_grade; 
   double avg_percent; 
   double highest, lowest;
   double avg_score;
   avg_score = ((temp1 + temp2 + temp3)/(n));
   avg_percent = ((temp1 + temp2 + temp3)/ (2*i));
   
   
   cout << "Number of students processed: " << i << "\n";
   
   
   if (temp1 > temp2 && temp1 > temp3)
   {
      highest = temp1;      
      cout << "Highest total points achieved: " << highest << "\n";
   }
   else if (temp2 > temp1 && temp2 > temp3)
   {
        highest = temp2;
        cout << "Highest total points achieved: " << highest << "\n";
   }  
   else if (temp3 > temp1 && temp3 > temp2)
   {
        highest = temp3;
        cout << "Highest total points achieved: " << highest << "\n";
   }
   
   
   if (avg_percent >=90)
   {
             avg_grade = 'A';
   }
   else if (avg_percent >= 80 && avg_percent < 90)
         {
             avg_grade = 'B';
         }
   else if (avg_percent >= 70 && avg_percent < 80)
         {
             avg_grade = 'C';
         }
   else if (avg_percent >= 60 && avg_percent < 70)
         {
             avg_grade = 'D';
         }
   else 
             avg_grade = 'F';
  
       

   if (temp1 < temp2 && temp1 < temp3)
   {
      lowest = temp1;      
      cout << "Lowest total points achieved: " << lowest << "\n";
   }
   else if (temp2 < temp1 && temp2 < temp3)
   {
        lowest = temp2;
        cout << "Lowest total points achieved: " << lowest << "\n";
   }  
   else if (temp3 < temp1 && temp3 < temp2)
   {
        lowest = temp3;
        cout << "Lowest total points achieved: " << lowest << "\n";
   }

   cout << "Average total points achieved: " << avg_score << "\n";
   cout << "Average letter grade achieved: " << avg_grade << "\n";
   cout << temp1 << endl << temp2 << endl << temp3;
}

You still have issues... Why don't you want to initialize your variables to 0 before using them?
Copy and paste is, well, Fine sometimes, but your have a logical problem here with your copy and paste of your 'record_3' section... You only provide the possibility of entering 3 records, why ask if the user want's to enter another? What happens if they say yes?
Why are you using globals AND passing them around (sometimes)...
In class_avg() you pass in 'i', and use it, but you also use the global 'n' that it is derived from...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.