-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
64 lines (55 loc) · 1.99 KB
/
Copy pathmain.cpp
File metadata and controls
64 lines (55 loc) · 1.99 KB
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
#include "unweighted_calculator.h"
#include "weighted_calculator.h"
#include <iostream>
#include <map>
int main() {
std::cout << "Welcome to Charlie Brown's Grade Calculator\n\n";
Calculator *calculator = nullptr;
char choice;
std::cout << "Choose calculator type:\n";
std::cout << "1. Unweighted (standard points-based)\n";
std::cout << "2. Weighted (category-based)\n";
std::cout << "Enter choice (1 or 2): ";
std::cin >> choice;
if (choice == '2') {
calculator = new WeightedCalculator();
std::map<std::string, float> category_weights;
int num_categories;
std::cout << "\nHow many grade categories do you have? ";
std::cin >> num_categories;
for (int i = 0; i < num_categories; i++) {
std::string category;
float weight;
std::cout << "Enter category name " << (i + 1) << ": ";
std::cin >> std::ws;
std::getline(std::cin, category);
std::cout << "Enter weight for " << category << " (in %): ";
std::cin >> weight;
category_weights[category] = weight;
}
static_cast<WeightedCalculator *>(calculator)
->setGradingScheme(category_weights);
} else {
calculator = new UnweightedCalculator();
int total_points;
float A_points, B_points, C_points, D_points;
std::cout << "Enter total course points: ";
std::cin >> total_points;
std::cout << "Enter minimum points needed for an A: ";
std::cin >> A_points;
std::cout << "Enter minimum points needed for a B: ";
std::cin >> B_points;
std::cout << "Enter minimum points needed for a C: ";
std::cin >> C_points;
std::cout << "Enter minimum points needed for a D: ";
std::cin >> D_points;
static_cast<UnweightedCalculator *>(calculator)
->setGradingScheme(total_points, A_points, B_points, C_points,
D_points);
}
calculator->inputAssignments();
calculator->calculateGrade();
calculator->displayResults();
delete calculator;
return 0;
}