-
Notifications
You must be signed in to change notification settings - Fork 0
/
Course.cpp
40 lines (33 loc) · 1.23 KB
/
Course.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
#include <iostream>
#include "Course.h"
Course::Course(std::string name) : m_name(name) {}
std::string Course::get_full_name() const {
return m_name;
}
double Course::calculate_final_grade(std::vector<double> practice, double exam) const {
double average = 0;
for (auto grade : practice)
average += grade;
average /= practice.size();
return (average * 3 + exam) / 4;
}
std::pair<std::vector<double>, double> Course::ask_for_grades() const {
std::pair<std::vector<double>, double> ans = std::make_pair(std::vector<double>(3), 0.0);
std::cout << "Introdu cele 3 note de la Lucrarile Practice pentru cursul " << get_full_name() << ":\n";
for (int i = 0; i < 3; i++) {
while (true) {
std::cin >> ans.first[i];
if (ans.first[i] >= 0 && ans.first[i] <= 10)
break;
std::cout << "\nEroare: nota trebuie sa fie un nr zecimal intre 1 si 10. Reintrodu nota: ";
}
}
std::cout << "Introdu nota de la examenul final: ";
while (true) {
std::cin >> ans.second;
if (ans.second >= 0 && ans.second <= 10)
break;
std::cout << "\nEroare: nota trebuie sa fie intre 1 si 10. Reintrodu nota: ";
}
return ans;
}