Write a program that prompts the use for the number of assignments in a specific class. Then using a for loop, prompt for each score. Use an accumulator to store the sum of the assignments, and then calculate the average score for the assignments.
HELP. I have no idea what's going on.

#include <iostream>

using std::cout;
using std::cin;

int main ()
{
    int number = 0,
        percent = 0;

    cout << "Enter number of assignments: ";
    cin >> number;

    for ( int assignments = 0; assignments < 5; assignments++ )
    {
        cout << "Enter percentage of assignment which you did correctly. Assignment " << assignments + 1 << ": ";
        cin >> percent;

        assignments += percent;
    }

    return 0;
}

Try writing the problem out in steps first. You can use pseudo-code (a combination of written language and computer language).

Prompt for number of assignments - "numAssignments"

for each assignment {
    Prompt for score - "enteredScore"

    totalScore = totalScore + enteredScore
}

averageScore = ....

Now convert that into code.
How do you write a proper for loop in C++? Convert the pseudo-code to a C++ for loop.

example data:
Score 1: 92
Score 2: 85
Score 3: 95

Using what I have above.

numAssignments = 3

How many assignments do you need to prompt for scores?
How can you write that in a for loop? Write it out on paper plugging in the values.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.