-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuse_stuc.cpp
46 lines (42 loc) · 916 Bytes
/
use_stuc.cpp
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
// use_stuc.cpp -- using a composite class
// compile with studentc.cpp
#include <iostream>
#include "studentc.h"
using std::cin;
using std::cout;
using std::endl;
void set (Student & sa, int n);
const int pupils = 3;
const int quizzes = 5;
int main()
{
Student ada[pupils] =
{Student(quizzes), Student(quizzes), Student(quizzes)};
int i;
for (i = 0; i < pupils; ++i) {
set(ada[i], quizzes);
}
cout << "\nStudent List:\n";
for (i = 0; i < pupils; ++i) {
cout << ada[i].Name() << endl;
}
cout << "\nResults:";
for (i = 0; i < pupils; ++i) {
cout << endl << ada[i];
cout << "average: " << ada[i].Average() << endl;
}
cout << "Done.\n";
return 0;
}
void set(Student & sa, int n)
{
cout << "Please enter the student's name: ";
getline(cin, sa);
cout << "Please enter " << n << " quiz scores:\n";
for (int i = 0; i < n; i++) {
cin >> sa[i];
}
while (cin.get() != '\n') {
continue;
}
}