Adding intrest

In my Computer science class we need to create a program that looks like this.

I am confused as to why the interest rate raises 0.02 then raises 0.01 and back to raising 0.02? How can I set this interval ?

Also can you assist me in how to find the total interest rate added (book page/website ok)

*Sorry about the bad formatting, I am new...*

#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <ctime>
using namespace std;
int main()
cout << "Accumulate interest on a savings account. \n";
cout << "Starting value is $100 and interest rate is 1.25%" << endl << endl;

int year = 1;
double interest = 1.25;
double total = 100.00;
double tot;
cout << fixed << showpoint << setprecision(2);

while (year <= 10)
total = total + interest;
cout << "Year " << year << " adds " << interest << " for a total of " << total << ".\n";
year = year + 1;
interest = interest + 0.02;
tot = interest + interest;

cout << "\n" << "Total Interest credited was " << tot << ".\n" << endl;
cout << "Completed Part 4." << endl << endl;
return 0;

I need this by tomorrow morning... Please Help~
interest would be calculated like this
RATE = 1.25;

interest = total * (RATE / 100);
Last edited on
You will want to use separate variables for your interest rate from your interest amount. Your main loop needs to be rethought. Do the calculations and then print the result. So, figure out your interest amount (Yanson's form is fine) and then add that to the total. Print the result. Increment the year. What is with that last line in the loop? It does not make sense in this context. To be able to print the total interest after the main loop, you will want to add the interest inside the loop, not outside.
Topic archived. No new replies allowed.