Using helper functions

I have to write a function that has 9 parameters and is type void. Four of the parameters are arrays the other 5 are variables. And this function is supposed to call on three helper functions to display a table. I have no clue how to do this because I don't really know what a helper function means or how to call one. I completed my code and it appears to be working as it should. Also we haven't gone over using class yet. Below are the functions that are meant to be the helper functions.

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
void table_top(const string & dashed_lines, const string & msg0, const string & msg1, 
const string & msg2, const string & msg3, const string & msg4){
// Displays top of table
  
  for(int i=0; i<47; i++){
    cout << dashed_lines;
  }
  cout << endl;
  
  cout << msg0 << setw(3) << " " << msg1 << setw(3) << " " << msg2 << 
setw(3) << " " << msg3 << setw(3) << " " << msg4 << endl;
  
  for(int i=0; i<47; i++){
    cout << dashed_lines;
  }
  cout << endl;
  
  return;
}

void table_middle(int & students, int exam1[], int exam2[], int exam3[], 
int exam_totals[], double & class_average){
// Displays middle of table
    
    for(int i=0; i<students; i++){
      cout << setw(6) << " " << i+1 << setw(3) << " " << setw(10) << left
 << exam1[i] << setw(10) << left << exam2[i]
           << setw(10) << left << exam3[i] << setw(6) << left << exam_totals[i];
      if(exam_totals[i]==class_average){
        cout << "=" << endl;
      }
      else if(exam_totals[i]>=class_average){
        cout << "+" << endl;
      }
      else if(exam_totals[i]<=class_average){
        cout << "-" << endl;
      }
    }
  return;
}


void table_bottom(int & students, double class_average, int & lowest, 
int & highest, int above_average){
// Displays bottom of table

  for(int i=0; i<47; i++){
    cout << "-";
  }
  
  cout << endl;
  cout << "The number of students is:" << setw(14) << " " 
<< students << endl;
  cout << "The avg total score (rounded) is:" << setw(7) << " " 
<< setprecision(0) << fixed << class_average << endl;
  cout << "The maximum total score is:" << setw(13) << " " 
<< highest << endl;
  cout << "The minimum total score is:" << setw(13) << " " 
<< lowest << endl;
  cout << "Total scores at or above the avg is:" << setw(4) << " " 
<< above_average << endl;
  
  for(int i=0; i<47; i++){
    cout << "-";
  }
  
  cout << endl;
  
  return;
}
Last edited on
Topic archived. No new replies allowed.