I would like to find the sum of the first column and divide it by the sum of the second column.
First column is score and second column is total possible per assignment.
For a program that calculates overall course grade and will take infinite input.
set sum_of_scores and sum_of_possibles to 0
while you can input a score and a possible ...
... add these to their sums
output sum_of_scores divided by sum_of_possibles
Schools are generally terrible at showing basic C++ I/O file streams, so here's something you can work with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
#include <fstream>
int main()
{
std::ifstream fin("input.txt");
// ... TODO ...
// while "successfully reading in the next actual score and possible score"
while (fin >> actual_score >> possible_score)
{
sum_actual_scores += actual_score;
sum_possible_scores += possible_score;
}
// ... TODO ...
}
First column is score and second column is total possible per assignment.
I would like to find the sum of the first column and divide it by the sum of the second column.
If you're trying to compute the average grade, your math may be wrong. The way you're computing it, each point of each assignment is worth the same amount, so a quiz with 20 points is worth twice as much as a quiz with 10 points. If you want each assignment to count the same as each other assignment, then you need to adjust your math.