-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path13-3grade.cpp
More file actions
36 lines (30 loc) · 748 Bytes
/
13-3grade.cpp
File metadata and controls
36 lines (30 loc) · 748 Bytes
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
#include <stdexcept>
#include <vector>
#include <algorithm>
#include <iostream>
#include "grade.h"
#include "median.h"
#include "Student_info.h"
#include "core.h"
#include "grad.h"
using std::domain_error; using std::vector;
using std::min;
double grade(double midterm, double final, double homework)
{
return 0.2 * midterm + 0.4 * final + 0.4 * homework;
}
double grade(double midterm, double final, const vector<double>& hw)
{
if (hw.size() == 0)
throw domain_error("student has done no homework");
return grade(midterm, final, median(hw));
}
// Modified for Ch. 13
double Core::grade() const
{
return ::grade(midterm, final, homework);
}
double Grad::grade() const
{
return min(Core::grade(), thesis);
}