153k views
2 votes
An online bank wants you to create a program that shows prospective customers how their deposits will grow. Your program should prompt the user for initial balance and the annual interest rate in percent. Choose double datatypes for variables to store initial balance and annual interest rate that you received from the user. Interest is compounded monthly. Computer and print out the balances after the first three months.

Test your program when user gives initial balance as 1000 and interest rate as 6.

1 Answer

3 votes

Answer:

Written in C++

#include<iostream>

#include<math.h>

using namespace std;

int main(){

double Amount, Rate;

cout<<"Initial Amount: ";

cin>>Amount;

cout<<"Rate: ";

cin>>Rate;

for(int i =1;i<=3;i++){

Amount = Amount *(pow((1+Rate/100),1));

cout<<"Balance: "<<Amount<<endl;

}

return 0;

}

Step-by-step explanation:

The program was written in C++ (The line by line explanation is as follows)

This line declares Amount and Rate as double

double Amount, Rate;

This line prompts user for Amount

cout<<"Initial Amount: ";

This line gets input for Amount

cin>>Amount;

This line prompts user for Rate

cout<<"Rate: ";

This line gets input for Rate

cin>>Rate;

The following iteration calculates and prints the new balance at the end of each month using compound interest formula

for(int i =1;i<=3;i++){

Amount = Amount *(pow((1+Rate/100),1));

cout<<"Balance: "<<Amount<<endl;

}

User Ken White
by
6.6k points