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;
}