From 743c47c671347a0ac0f8f64b7117b48c65bab073 Mon Sep 17 00:00:00 2001 From: Oskar Date: Thu, 29 Aug 2024 13:27:45 +0200 Subject: more --- 5p5.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 5p5.cpp (limited to '5p5.cpp') diff --git a/5p5.cpp b/5p5.cpp new file mode 100644 index 0000000..b4aeff5 --- /dev/null +++ b/5p5.cpp @@ -0,0 +1,37 @@ +#include +#include + +/* + * + * 5.5 + * + * + */ + +int main () { + + int TestScore = 0; + std::vector GradeLetters = {"F", "D", "C", "B", "A", "A++"}; + std::string FinalGrade; + if(std::cin >> TestScore) {} else { return -1; } + + if(TestScore < 0 || TestScore > 100) { return -1; } + + if(TestScore < 60) { + FinalGrade = GradeLetters[0]; + } else { + if(TestScore != 100) { + FinalGrade = GradeLetters[(TestScore-50) / 10]; + if((TestScore % 10) > 7) { + FinalGrade += "+"; + } else if((TestScore % 10) < 3) { + FinalGrade += "-"; + } + } else { + FinalGrade = GradeLetters[5]; + } + } + + std::cout << "Your grade is: " << FinalGrade << std::endl; + return 0; +} -- cgit v1.2.3