Need help with part of this problem.

Ill give the problem Im working on before I ask what part of it I need help with.

Effective January 1st of each year, Gabriela receives a 5% raise on her previous years salary. She wants a program that calculates and displays the amount of her annual raises for the next three years. The program also should calculate and display her total salary for the three years.
-Desk check the program using an annual salary of 10,000. (The raise amounts are 500.00, 525.00 and 551.25. The total salary for the three years being 33,101.25.)

We have to use a while loop or a for loop for this problem. While I understand how they work, I can't quite figure how after you do the raise amounts, how to get the program to display the total salary for the 3 years. Since it has to display the raise amounts and then the total. How do you get the total salary at the end after the loop? Since the loop would run I assume 3 times before the total salary is given.
#include <iostream>
#include <iomanip>
using namespace std;

const double RATE = 0.05;

int main()
{
double salary = 0.0;
double totalSalary = 0.0;

cout << "Enter the salary:" << endl;
cin >> salary;

for(int counter = 0; counter <3; counter++)
{
salary *= (1.0 + RATE);
cout << fixed << setprecision(2);
cout << salary << endl;
totalSalary += salary;
}

cout << fixed << setprecision(2);
cout << "The total salary is " << totalSalary << endl;

return 0;
}


Nevermind, I figured it out after tinkering with it!
Topic archived. No new replies allowed.