I need to find both functions here...

So I need to find both functions in this program, I already know that there is no return value since its a void function. Any takers to help me out..?

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
#include <iostream>
using namespace std;
// PrintClassGrades.cpp


int main()
{
   // prototypes
   void printStudentGrade(double average, int studentNumber);
   void printClassGrade(double average);

   const int NUMBER_OF_GRADES = 2;
   const int NUMBER_OF_STUDENTS = 4;

   double grade = 0.0;
   double studentTotal = 0.0;
   double studentAverage = 0.0;
   double classTotal = 0.0;
   double classAverage = 0.0;

   for (int i = 0; i < NUMBER_OF_STUDENTS; i++)  // start of outer loop
   {
      studentTotal = 0;           // clear the total for this student

      for (int j = 0; j < NUMBER_OF_GRADES; j++)    // start of inner loop
      {
         cout << "Student #"<< (i + 1) << " "
         << "Enter examination score #" << (j + 1) << ": ";
         cin  >> grade;

         // student total
         studentTotal = studentTotal + grade;
      }                             // end of the inner for loop

      // calculate student average
      studentAverage = studentTotal / NUMBER_OF_GRADES;

      // print student average
      printStudentGrade(studentAverage, (i + 1));

      // add student total to class total
      classTotal = classTotal + studentTotal;
   }                               // end of the outer for loop

   // compute class average
   classAverage = classTotal / (NUMBER_OF_STUDENTS * NUMBER_OF_GRADES);

   // function call: class average
   printClassGrade(classAverage);

   cin.get();
   return 0;
}

/* Sample Output (from PrintClassGrades.cpp)
   Student #1 Enter examination score #1: 77
   Student #1 Enter examination score #2: 88
   The average for student #1 is 82.5

   Student #2 Enter examination score #1: 77
   Student #2 Enter examination score #2: 99
   The average for student #2 is 88

   Student #3 Enter examination score #1: 77
   Student #3 Enter examination score #2: 66
   The average for student #3 is 71.5

   Student #4 Enter examination score #1: 87
   Student #4 Enter examination score #2: 86
   The average for student #4 is 86.5

   The average for class is 82.125
   Press any key to continue . . .
*/

//-------------------------------------------------------------------
// Code the following two output functions
//-------------------------------------------------------------------
// Output Function - code the printStudentGrade() function below
// parameters: studentAverage :  double
//             studentNumber  :  int
// returns: none

// Output Function - code the printClassGrade() function below
// parameters: classAverage :  double
// returns: none
//-------------------------------------------------------------------



For the first output function I got this:

1
2
3
4
5
printClassGrade (double studentAverage, int studentNumber)
{
cout << "studentTotal / NUMBER_OF_GRADES" << endl;
}


For my second output function I came up with the following:

1
2
3
4
5
printClassGrade (double classAverage)
{
cout << "classTotal / (NUMBER_OF_STUDENTS * NUMBER_OF_GRADES)" << endl;
}
Any thoughts anyone..? Does this make sense..??
You're just printing out a text message in the cout << statements. You need a combination of "text" and variable names here.

The numbers in the output here come from the studentAverage and studentNumber values that were passed to the function.

The average for student #1 is 82.5


The number in the output here comes from the classAverage value that was passed to this function.

The average for class is 82.125


Don't forget to put void to the left of the function name so the program knows the function doesn't return a value.
Can anyone please guide me and show me how this one is done cuz I have no damn clue...?? /: and It's driving me insane..!!
The output statement that's already in your main function is an example of combining text output and variable content in one line. Straight text is put between double quotes, the variable name is as is without quotes (e.g. i or j).

cout << "Student #"<< (i + 1) << " " << "Enter examination score #" << (j + 1) << ": ";
ok so is that what the correct output function would be than..?
It's a guide to follow to build the ones you want for the other functions.

The numbers in the output here come from the studentAverage and studentNumber values that were passed to the function.

The average for student #1 is 82.5


The number in the output here comes from the classAverage value that was passed to this function.

The average for class is 82.125
I guess my whole issue really is that I dont understand really what it is Im trying to code in the output function like something is frickin not triggering my lightbulb on what it is exactly is steps and detail and clear easy breakdown of how to accomplish this task.../:
1
2
3
4
5
6
printStudentGrade (double studentAverage, int studentNumber)
{
 cout << " The average for student # " << studentAverage << endl;
}

Ok this is what I come up for the first function now..is this improvement..?? Anyone..??
You've got the idea :) - that'll output this.

 The average for student #  82.5


So now you just want to add in the studentNumber and text for " is ".
And don't forget to add void to the left of the function name.
Topic archived. No new replies allowed.