Answer to Question #204494 in C++ for Emmanuel Stevens

Question #204494

Mr. James wanted to calculate his interest at the Bank of Sierra Leone, with a specific amount deposited, Time and Rate. Write C++ console program of functions to calculate the interest of Mr. James. The console application should asked the user to input values of Time, Rate and Amount deposited.


1
Expert's answer
2021-06-08T09:32:47-0400
#include <iostream> 


using namespace std;


float calculateInterest(int time, float rate,float amountDeposited);


int main (){
	int time=-1;
	float rate=-1;
	float amountDeposited=-1;
	while(time<=0){
		cout<<"Enter time period of the deposit in years: ";
		cin>>time;
	}
	while(rate<=0 || rate>100){
		cout<<"Enter rate of interest [1-100%]: ";
		cin>>rate;
	}
	while(amountDeposited<=0){
		cout<<"Enter amount deposited: ";
		cin>>amountDeposited;
	}
	
	float interest= calculateInterest(time,rate,amountDeposited);


	cout<<"\nInterest: "<<interest<<"\n\n";


	system("pause");
	return 0;
}
//Calculates interest
float calculateInterest(int time, float rate,float amountDeposited){
	return (time*rate*amountDeposited)/100.0;
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog