diff --git a/tut33.cpp b/tut33.cpp new file mode 100644 index 0000000..901e6b0 --- /dev/null +++ b/tut33.cpp @@ -0,0 +1,67 @@ + +#include +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<>p>>y>>r; +bd1 = BankDeposit(p,y,r); +bd1.show(); + +cout<<"Enter the value of p y and r"<>p>>y>>r; +bd2 = BankDeposit(p,y,r); +bd2.show(); + + + return 0; +} \ No newline at end of file