ExamGrader
)double
.
WeightedAverager
)Weighted averages are typically expressed by specifying the percentage that each element contributes to the average. The percentages must sum to 100% for the average to be correct. To calculate the average, each element is multiplied by it's percentage (don't forget, 50% is actually .50), and the products then summed producing the average.
(Another way of calculating the weighted average is to treat each exam as counting for its percentage points out of 100 and then dividing the total by
100 (this works if you are restricting the calculations to integers and thus can't use something like .50
). For example if an exam is worth
65%, you multiply the score by 65; f the other one is then 35%, you multiply it by 35, and after you've added those amount together, you divide by 100.)
Write a program that prompts the user for a project, midterm and final and displays their weighted average (as a floating point,
i.e., double
) according to the following table:
Project | 20% |
Midterm | 30% |
Final | 50% |
(Notice this is very similar yo the previous lab, but with weighted averages, and the prompts and output are different … but it still makes sense
to copy Lab 2.1
for your starting point. Starting from a similar program is often simpler than starting from scratch and a useful skill to master.)
Sample Test Run
Here is a sample execution of the program. User input is in bold. Your program should replicate the prompts and output:
WeightedAverager
) Approval
Modify Lab 2.2
so that the user is prompted for the weights of the exams (see sample run).
Sample Test Run
Here is a sample execution of the program. User input is in bold. Your program should replicate the prompts and output: