0% found this document useful (0 votes)
6 views2 pages

C++ Project

This C++ project calculates the GPA based on user input of course grades. It prompts the user to enter the number of courses taken and their respective grades, then assigns grade points to each grade. Finally, it computes and displays the GPA by dividing the total grade points by the total credit hours.

Uploaded by

hct5jj4rxm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

C++ Project

This C++ project calculates the GPA based on user input of course grades. It prompts the user to enter the number of courses taken and their respective grades, then assigns grade points to each grade. Finally, it computes and displays the GPA by dividing the total grade points by the total credit hours.

Uploaded by

hct5jj4rxm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

C++ PROJECT

Introduction to computing

Youssef Harby Fawzy


Registration number: 241013076
#include <stdio.h>
# define creditHours 3
#include <string.h>
int main() {
int courseNumber;
// variable declaration //
char courseGrade[3];
float GPA, gradePoints, gradepointsTotal = 0;
printf("Please input the number of course you have taken this semster: \n");
scanf("%d", &courseNumber);
printf("please input the grade of each course: \n");
for(int i = 0; i < courseNumber; i++){
scanf("%s", &courseGrade); // for loop to input multiple grades //
if(strcmp(courseGrade,"A+") == 0){
gradePoints = 4.00;}
if(strcmp(courseGrade,"A") == 0){
gradePoints = 3.88;}
if(strcmp(courseGrade,"A-") == 0){
gradePoints = 3.66;}
if(strcmp(courseGrade,"B+") == 0){
gradePoints = 3.33;}
if(strcmp(courseGrade,"B") == 0){
gradePoints = 3.00;} // if conditions to assign each grade
if(strcmp(courseGrade,"B-") == 0){ letter to numeric points //
gradePoints = 2.66;}
if(strcmp(courseGrade,"C+") == 0){
gradePoints = 2.33;}
if(strcmp(courseGrade,"C") == 0){
gradePoints = 2.00;}
if(strcmp(courseGrade,"C-") == 0){
gradePoints = 1.66;}
if(strcmp(courseGrade,"D+") == 0){
gradePoints = 1.33;}
if(strcmp(courseGrade,"D") == 0){
gradePoints = 1.00;}
if(strcmp(courseGrade,"F") == 0){
gradePoints = 0;} // operation to calculate total grade
gradepointsTotal = gradepointsTotal + gradePoints; points //
}

GPA = gradepointsTotal / (creditHours * courseNumber); // Operation to calculate GPA //


printf("Your GPA is: %f", GPA);

return 0;
}

You might also like