-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparticipation_grader.cpp
More file actions
53 lines (42 loc) · 1.74 KB
/
participation_grader.cpp
File metadata and controls
53 lines (42 loc) · 1.74 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
#include <iostream>
// P A R T I P A T I O N G R A D E R
/*
This script calculates the GCU Online Class Participation grade (out of 20 points), based on
needing a minimum of 6 (substantive) posts over 3 days.
*/
using namespace std::string_literals;
const auto MIN_SUBSTANTIVE_POSTS = 6.0f;
const auto MIN_DAYS_POSTED = 3.0f;
constexpr auto FULL_POINTS = 20.0f;
struct Grade
{
float points;
float percentage;
};
Grade calculate_participation_grade(const unsigned int substantive_posts, const unsigned int days_posted)
{
// Calculate substantive posts portion (out of 10)
constexpr auto full_points_substantive_posts = FULL_POINTS / 2.0f;
const auto substantive_posts_points = (substantive_posts / MIN_SUBSTANTIVE_POSTS) * full_points_substantive_posts;
// Calculate days posted portion (out of 10)
constexpr auto full_points_days_posted = FULL_POINTS / 2.0f;
const auto days_posted_points = (days_posted / MIN_DAYS_POSTED) * full_points_days_posted;
// Calculate total
const auto total_points = substantive_posts_points + days_posted_points;
const auto total_percent = total_points / FULL_POINTS;
auto grade = Grade{.points = total_points, .percentage = total_percent};
return grade;
}
int main()
{
// Get substantive posts and days posted
unsigned int substantive_posts;
unsigned int days_posted;
std::cout << "How many substantive posts?: "s;
std::cin >> substantive_posts;
std::cout << "How many days posted?: "s;
std::cin >> days_posted;
const auto participation_grade = calculate_participation_grade(substantive_posts, days_posted);
std::cout << "Participation Grade: "s << participation_grade.points << " ("s << participation_grade.percentage << ")"s << std::endl;
return 0;
}