Grading Calculator

My grading calculator calculates if a person passes or fails their term (part of a trimester) in a school year. It also shows how many points a person needs in order to achieve certain achievements (w/honors, w/high honors, w/highest honors). In this blog, I will show you my rundown in my attempt to make a grading calculator using Dev C++.


My Information and Communications Technology (ICT) teacher in software gave my class our final project to work on for our first term. The project was about creating our own program strictly following the lessons that have been taught to us from the very first lesson of the term. However, she posted a challenge wherein we are not allowed to use advance concepts in C++ outside the lessons taught to me and my classmates. Usage of concepts outside the parameters given by our teacher will deduct points to our final grade of our project. These lessons include:

  2. Data Types
  3. Assignment Operators
  4. Logic Operators
  5. Relational Operators
  6. Short Hand Operators

All of these are the lessons that we get to choose from for our own program. I should point out that it is not necessary to use all of these concepts because it is entirely up to us to choose what kind of program we want to make. I also got to ask my teacher if we could use ternary operators to incorporate the logic operators. Fortunately, she granted my request.


I knew from the start that I wanted to make something that would incorporate all the lessons that my teacher had taught me and my classmates to achieve a high score. Quite suddenly, I recalled a certain classmate of mine who made a grading calculator in C++ and shared it to my class. He shared his project before the final project was even announced so it was okay. Therefore, all I did was improve upon his project and I tried to make it my own.

#include <iostream>
using namespace std;

int main() {
	// This program will display a person's grade's statistics.
	//declaration of variable
	float aGrade, tGrade, resultingMark;
	string result, aComputation, tComputation, pointOrPoints;
	bool mark;
	//prompt user
	cout << "Greetings! This program will display your \ngrade's statistics based on your input.\n\n";
	cout << "Academic average grade: ";
	cin >> aGrade;
	cout << "Technical average grade: ";
	cin >> tGrade;
	cout << endl;
	return 0;

Note that the code above was not made by my classmate but of my own work.

The first problem was identifying whether or not the user had a passing or failing grade. Unfortunately, ternary operators return certain data types and therefore cannot be printed out directly. Therefore, I had to put the ternary operators inside a variable and then print out its content.

I then declared the variables with comments above them. I had to think critically about the variables as to not waste any memory. Then, I made a prompt for my user’s average for both academic and technical grades.

result = (aGrade >= 75 && !(aGrade > 100)) ? (aGrade >= 90 && !(aGrade >= 94)) ? "w/honors": (aGrade >= 94 && !(aGrade >= 97)) ? "w/high honors" : (aGrade >= 97) ? "w/highest honors" : "Passed": 
	(aGrade > 100) ? "ERROR! Grade should not pass mark 100.0" : (aGrade < 70) ? "ERROR! Grade should not be below 70.0" : "Failed";
	cout << "Academic remarks: " << result << endl << endl;

This code snippet alone took about thirty minutes of my precious time. I had to account for the user’s input above 100 and below 70. This would limit the user to the inputs 70 to 100. Then, I calculated if they have passed or failed. Finally, if the user had a passing grade, then I still have to check whether or not their grades were above 90, 94, & 97. These certain marks are what make my grading calculator unique. It tells the user if they have received awards for the term. This was both for academic and technical grades. It’s also worth noting that this was my first time using ternary operators in C++ so it did take some time before I was able to solve for it.

resultingMark = 94 - aGrade;
	mark = (resultingMark <= 0 && !(resultingMark < -6)) ? true : false;
	aComputation = (mark) ? "has achieved mark by a difference of " : (resultingMark < -6) ? "ERROR! Grade should not pass mark 100." : 
	(aGrade < 70 && !(aGrade == 70)) ? "ERROR! Grade should not be below 70." : "requires an additional ";
	resultingMark = (mark && !(resultingMark == 0)) ? round(resultingMark * 100) / -100: (resultingMark < -6) ? 0 : (aGrade < 70) ? 0 : round(resultingMark * 100) / 100;
	pointOrPoints = (resultingMark > 1) ? " points" : (resultingMark < -6) ? "" : (resultingMark == 0) ? "" : " point";
	cout << "\tw/high honors: " << aComputation << resultingMark << pointOrPoints << endl;

This code snippet calculates how many points are needed to reach the award for w/high honors. If the person has already surpassed the mark, then the calculator would display how much points were surpassed.

For each achievement, the same operations were made but different values. i.e. w/honors (resultingMark = 90 – aGrade), w/highest honors (resultingMark = 97 – aGrade)

Finally, for the final part of my program. I included my project in my repository on Bitbucket. My teacher didn’t specify that including my project on a repository would deduct points from my final project. Therefore, I included it to my Bitbucket to remember certain projects like these when I grow older. I like to archive as much of my programs as possible lest not to forget them when I grow older =)

Final output:

Greetings! This program will display your
grade's statistics based on your input.

Academic average grade: 93.5 // user input
Technical average grade: 100 // user input

Academic remarks: w/honors
Points to reach marks:
w/honors: has achieved mark by a difference of 3.5 points
w/high honors: requires an additional 0.5 point
w/highest honors: requires an additional 3.5 points. 

Technical remarks: w/highest honors
Points to reach marks:
w/honors: has achieved mark by a difference of 10 points
w/high honors: has achieved mark by a difference of 6 points
w/highest honors: has achieved mark by a difference of 3 points

Thank you for making use of this program =)

Overall, I had fun with my final project. I was slightly challenged by the ternary operators. However, I still feel as if I could have done more for this program.

This was how convoluted my program became because I recycled the variables I had made to save memory.

You can find the repository for this project on Bitbucket:

Leave a Reply

Your email address will not be published. Required fields are marked *