From a9797cd855c9567e8ffb68fc4c7b12e7cf7e55d8 Mon Sep 17 00:00:00 2001 From: Preetishah18 <113947723+Preetishah18@users.noreply.github.com> Date: Thu, 27 Oct 2022 17:25:43 +0530 Subject: [PATCH] hacktoberfest2022 --- tut33.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tut33.cpp 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