Answer to Question #173075 in C++ for Vimal D

Question #173075

Declare a class Fixed_Deposit with member variables are principal, rate and time, and member functions are MaturityAmount() to calculate the compound interest and maturity amount, and display() to print the total maturity amount(principal+compound interest).


1
Expert's answer
2021-03-19T17:57:38-0400
#include <iostream>
 
using namespace std;
 
class Fixed_Deposit
{
public:
	Fixed_Deposit(double principale_, double rate_, int time_);
	double MaturityAmount();
	void display();
private:
	double principale;
	double rate;
	int time;
};
 
Fixed_Deposit::Fixed_Deposit(double principale_, double rate_, int time_) : principale(principale_), rate(rate_), time(time_) {}
 
double Fixed_Deposit::MaturityAmount()
{
	return principale * (1 + rate * time);
}
 
void Fixed_Deposit::display()
{
	cout << "Principal is: " << principale << ". Compound interest is: " << principale * rate * time << endl;
	cout << "Total maturity amount is: " << MaturityAmount();
}
 
int main()
{
	Fixed_Deposit Dep = Fixed_Deposit(15000, 0.015, 2);
	Dep.display();
	cout << endl;
	return 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
APPROVED BY CLIENTS