For this final, you will be writing a program that will compute a user’s semester grade. A semester grade is calculated with the following weighted quarters and final: quarter 1 – 40%, quarter 2 – 40%, and the semester final – 20%. Once calculated, you must add them together and print out the user’s grade for the semester, not just their percent. Use the float function when getting input. The grades are as follows:
A: 89-100
B: 79 – 88
C: 69-78
D: 59-68
F: <58
To compute a user’s semester grade based on the given weights, you can follow these steps to write your program:
1. Get Input: Use the `float` function to get the grades for the two quarters and the final exam from the user.
2. Calculate Weighted Average: Multiply each grade by its respective weight (40% for each quarter and 20% for the final).
3. Sum the Weighted Grades: Add the weighted grades together to get the total semester grade.
4. Determine Letter Grade: Use conditional statements to determine the letter grade based on the total percentage calculated.
5. Print the Result: Display the semester grade and the corresponding letter grade.
Here’s a sample Python program that accomplishes this:
# Get user input for the grades
quarter1 = float(input("Enter your grade for Quarter 1: "))
quarter2 = float(input("Enter your grade for Quarter 2: "))
final_exam = float(input("Enter your grade for the final exam: "))
# Calculate the weighted grade
semester_grade = (quarter1 * 0.4) + (quarter2 * 0.4) + (final_exam * 0.2)
# Determine the letter grade
if 89 <= semester_grade <= 100:
letter_grade = 'A'
elif 79 <= semester_grade <= 88:
letter_grade = 'B'
elif 69 <= semester_grade <= 78: