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).
#include <iostream>
class Fixed_Deposit {
public:
float MaturityAmount()
{
float percent;
float amount;
percent = (rate * time/360)/100;
amount = principal * percent;
return amount;
}
void display()
{
std::cout << "Total maturity amount " << principal + MaturityAmount();
}
float principal;
float rate;
float time;};
int main()
{
Fixed_Deposit example;
return 0;
}
Comments
Leave a comment