not sure what to do here 19 In this exercise you will modify
not sure what to do here
Solution
/* Programme Begins */
#include<iostream> //header for inputs operations
#include <iomanip> //// std::setprecision if you want use
using namespace std;
void getBalance(int,float,float); //function declaration to display balance
int main()
{
int deposit,t,i; //varible declarations
float minr,maxr;
//reading principal amount ,intrest rates min,max with prompts asking input
cout<<\"Enter Deposit Amount : \";
cin>>deposit;
cout<<\"Enter Minimum Rate(in decimal form) : \";
cin>>minr;
cout<<\"Enter Minimum Rate (in decimal form) : \";
cin>>maxr;
getBalance(deposit,minr,maxr); //calling get balance method with arguments deposit amount,min & max rates
return 0;
}
void getBalance(int dep,float min,float max)
{
float rate,year1total,year2total,year3total; //declare varibles
for(rate=min;rate<=max;rate=rate+0.01 ) //loop repeates between min ,max interest rates with incrementation 0.01
{
cout<<\"Rate \" << min*100 << \"% : \"<<endl;
year1total= dep+(dep*rate*1);
cout<<\"Year \" << 1 << \" : $\"<< year1total <<endl; //find year 1 interest rate and display toatal
year2total= year1total+(year1total*rate*1);
cout<<\"Year \" << 2 << \" : $\"<< year2total <<endl; //find year 2 interest rate and display toatal
year3total= year2total+(year2total*rate*1);
cout<<\"Year \" << 3 << \" : $\"<< year3total <<endl; //find year 3 interest rate and display toatal
}
}
Output :
Enter Deposit Amount : 1000
Enter Minimum Rate(in decimal form) : 0.02
Enter Minimum Rate (in decimal form) : 0.04
Rate 2% :
Year 1 : $1020
Year 2 : $1040.4
Year 3 : $1061.21
Rate 2% :
Year 1 : $1030
Year 2 : $1060.9
Year 3 : $1092.73
Rate 2% :
Year 1 : $1040
Year 2 : $1081.6
Year 3 : $1124.86

