Build a GPA calculator that inputs grades of 3 different subjects along with the credit hours
from the user and displays the user’s GPA. The input grades and their corresponding grading
points are given below.
Grade Points
A 4.0
A- 3.67
B+ 3.33
B 3.0
B- 2.67
C+ 2.33
C 2.0
C- 1.67
D+ 1.33
D 1.0
F 0
The formula is
GPA = (GP1 * CH1 + GP2 * CH2 + GP3 * CH3)/ (CH1 + CH2 + CH3)
Where GP1 is Points of Subject 1 and CH1 show credit hours of subject 1.
GP1=int(input("Enter grade 1: "))
CH1=int(input("Enter credit hour for grade 1:"))
GP2=int(input("Enter grade 2: "))
CH2=int(input("Enter credit hour for grade 2:"))
GP3=int(input("Enter grade 3: "))
CH3=int(input("Enter credit hour for grade 3:"))
GPA = (GP1 * CH1 + GP2 * CH2 + GP3 * CH3)/ (CH1 + CH2 + CH3)
print(GPA)
Comments
Leave a comment