Stuck with this code

Sep 28, 2014 at 11:57pm
Write a program that calculates the total grade for N classroom exercises as a percentage. The user should input the value for N followed by each of the N scores and totals. Calculate the overall percentage (sum of the total points earned divided by the total points possible) and output it as a percentage. sample input (in bold) and output (in italics) is shown below.

How many exercises to input? 3

Score received for exercise 1: 10
Total points possible for exercise 1: 10

Score received for exercise 2: 7
Total points possible for exercise 2: 12

Score received for exercise 3: 5
Total points possible for exercise 3: 8

Your total is 22 out of 30, or 73.33%.

Input Details: The input will consist of an initial integer (let's refer to it as N) followed by N pairs of integers, all responses to program prompts.

Output Details: The program uses the prompts and labels shown in the example above.


This is the code I have so far, but I'm not quite sure where to go from here. Can anyone help?

#include
using namespace std;

int main()
{
int numExercises;
int TotalScore=0;
int PossiblePoints=0;

cout << "How many exercises to input?" << endl;
cin >> numExercises;

for (int i = 1; i <= numExercises; i++)
{
cout << "Score received for Exercise " << i << " ";
int score;
cin >> score;
TotalScore += score;
cout << "Total points possible for Exercise " << i << " ";
int points;
cin >> points;
PossiblePoints += points;
}
Sep 29, 2014 at 12:00am
It seems to me all you need to do now is output the TotalScore out of the PossiblePoints, and the percentage.
Sep 29, 2014 at 1:00am
Think you could help me put the code together for that?
Sep 29, 2014 at 1:15am
What do you need help with? All it requires is some output, which you did just fine in your code above.
Sep 29, 2014 at 1:31am
Oh, I already got it working. Thanks for your comment tho, it really helped.
Topic archived. No new replies allowed.