72.6k views
5 votes
The user is able to input grades and their weights, and calculates the overall final mark. The program should also output what you need to achieve on a specific assessment to achieve a desired overall mark. The program should be able to account for multiple courses as well.

I have done some pseudocode. So to double check, please provide pseudocode and python code.
I do plan to use homework, quizzes and tests for the grades portion and using the exam as part of the desired mark portion.

1 Answer

5 votes

Answer:

Here is some pseudocode that outlines the steps for creating a program that calculates overall final marks and outputs the necessary grades for a desired overall mark:

DEFINE a function called "calculate_final_mark"

INPUT: grades (list), weights (list), desired_mark (float)

CREATE a variable called "overall_mark" and set it to 0

FOR each grade and weight in the grades and weights lists:

MULTIPLY the grade by the weight

ADD the result to the overall_mark

IF overall_mark equals the desired_mark:

OUTPUT "You have already achieved the desired mark."

ELSE:

CREATE a variable called "needed_mark" and set it equal to the desired_mark minus the overall_mark

OUTPUT "You need a" needed_mark "on your next assessment to achieve a" desired_mark "overall mark."

END the function

Here is the equivalent code in Python:

def calculate_final_mark(grades, weights, desired_mark):

overall_mark = 0

for grade, weight in zip(grades, weights):

overall_mark += grade * weight

if overall_mark == desired_mark:

print("You have already achieved the desired mark.")

else:

needed_mark = desired_mark - overall_mark

print(f"You need a {needed_mark} on your next assessment to achieve a {desired_mark} overall mark.")

User Unferth
by
7.6k points