Today’s topic is a CGPA (Cumulative Grade Point Average) calculator. We will build the calculator's logic and code it in C++.
PROLOUGE: As we know, colleges and universities take semester-wise exams, and we get scores between 0 and 10. This is called SGPA(Semester Grade Point Average), and CGPA is the average of the total number of semesters, which will also be 0 to 10.
STRUCTURE: Firstly, we ask for the number of semesters and store it in a variable. Then, we continuously ask for the SGPA for each semester. Our code automatically adds all the semester numbers simultaneously and stores them in a variable. Lastly, it gives us the CGPA by calculating the average of the semester numbers.
CGPA = Total number of all semesters / Number of semester
LOGIC:
STEP 1: First take a variable name numOfSems. It will be a user input variable, after giving the value it will go to the if-else condition. If the value is less than 0 then it’s will show “enter invalid details” else it passes through to the next condition.
STEP 2: Then take a floating variable named sgpa which will take the value of all semester results. But we have to run a loop for the all-semester result value so we will run a for loop index at 1 to number of semesters by user.
It will check if the value is less than 0 or greater than 10 it will show “enter the invalid value” and give you the chance to correct till your correction(It will done by while loop)
STEP 3: Then again we take a floating variable named total GPA to add all the results of the semester. Calculate the CGPA by dividing the total cgpa by the number of semesters
The Code:
GitHub link:- https://github.com/Tanaygit646/CGPA-calculator-
Thanks for watching my project. It’s a beginner-level project but great success comes from little progress. If you want to watch my cgpa calculator in HTML, CSS, and JavaScript, go to this link.
blog link——>https://cgpa-calculator-by-htmlcssjs.hashnode.dev/