Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions tut33.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

#include <iostream>
using namespace std;

class BankDeposit
{
int principal;
int years;
float interestRate;
float returnValue;

public:
BankDeposit() {};
BankDeposit(int p, int y, float r); //r can be a value like 0.04
BankDeposit(int p, int y, int r); //r can be a value like 14;
void show ();

};
BankDeposit :: BankDeposit(int p, int y, float r)
{
principal = p;
years = y;
interestRate = r;

returnValue = principal;
for (int i = 0; i < y; i++)
{
returnValue = returnValue * (1 + interestRate);
}
}
BankDeposit :: BankDeposit(int p, int y, int r)
{
principal = p;
years = y;
interestRate = float(r)/100;

returnValue = principal;
for (int i = 0; i < y; i++)
{
returnValue = returnValue * (1 + interestRate);
}
}
void BankDeposit :: show(){
cout<<endl<<"Principal amount was "<<principal<<endl
<<"Return value after "<<years<<" years is "<<returnValue<<endl;
}
int main()
{
BankDeposit bd1,bd2,bd3;
int p,y;
float r;
int R;

//bd3.show();
cout<<"Enter the value of p y and r"<<endl;
cin>>p>>y>>r;
bd1 = BankDeposit(p,y,r);
bd1.show();

cout<<"Enter the value of p y and r"<<endl;
cin>>p>>y>>r;
bd2 = BankDeposit(p,y,r);
bd2.show();


return 0;
}