The Course Grade
Brackenhill College issues one final grade per student, but the pieces of work behind it do not count equally — a final exam carries far more weight than a weekly quiz. Every assessment therefore arrives with a weight beside its score, and the registrar wants the weighted mean: the average in which an assessment carrying twice the weight of another pulls the result twice as hard. Weight scales differ between courses and are not guaranteed to add up to 1.
Task: Print the student's weighted mean score.
Input
The first line holds one integer n, how many assessments follow. Each of the next n lines holds two values separated by a single space: the score first, then that assessment's weight. Either value may carry a decimal point. Every weight is greater than zero.
Output
One line holding the weighted mean with exactly two digits after the decimal point.
Example:
Input:
3
80 0.2
90 0.3
70 0.5
Output:
78.00
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in