-
Notifications
You must be signed in to change notification settings - Fork 1
/
11-5.cpp
51 lines (45 loc) · 1.42 KB
/
11-5.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
47
48
49
50
51
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <fstream>
#include <stdexcept>
#include <string>
#include <vector>
#include "grade.h"
#include "Student_info.h"
#include "analysis.h"
#include <sstream>
using std::cin; using std::setprecision;
using std::cout; using std::sort;
using std::domain_error; using std::streamsize;
using std::endl; using std::string;
using std::max; using std::vector;
using std::ifstream; using std::istringstream;
int main()
{
// students who did and didn't do all of their homework
vector<Student_info> did, didnt;
// read the students records and partition them
Student_info student;
while (student.read(cin)) {
if (student.did_all_hw())
did.push_back(student);
else
didnt.push_back(student);
}
// verify that the analysis will show us something
if (did.empty()) {
cout << "No student did all the homework!" << endl;
return 1;
}
if (didnt.empty()) {
cout << "Every student did all the homework!" << endl;
return 1;
}
// do the analyses
write_analysis(cout, "median", median_analysis, did, didnt);
write_analysis(cout, "average", average_analysis, did, didnt);
write_analysis(cout, "median of homework turned in", optimistic_median_analysis, did, didnt);
return 0;
}