Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are a programmer for the Home Software Company. You have been assigned to de

ID: 3720260 • Letter: Y

Question

You are a programmer for the Home Software Company. You have
been assigned to develop a class that models the basic workings of a
bank account. The class should have the following properties:
• Balance: Holds the current account balance.
• IntRate: Holds the interest rate for the period.
• Interest: Holds the interest earned for the current period.
• Transactions: Holds the number of transactions for the
current period. The class should also have the following
methods:
MakeDeposit Takes an argument, which is the amount of the
deposit. This argu- ment is added to the Balance
property.
Withdraw Takes an argument that is the amount of the
withdrawal. This value is subtracted from the
Balance property, unless the with- drawal amount is
greater than the balance. If this happens, an error
message is displayed.
CalcInterest This method calculates the amount of interest for
the current period, stores this value in the Interest
property, and adds it to the Balance property.
Demonstrate the class in an application that performs the following tasks:
• Allows deposits to be made to the account.
• Allows withdrawals to be taken from the account.
• Calculates interest for the period.
• Reports the current account balance at any time.
• Reports the current number of transactions at any time

Language C++

Explanation / Answer

#include<iostream>

using namespace std;

class Bank

{

private:

double balance;

int intRate;

double Interest;

int transaction;

public:

Bank() //constructor

{

balance=0;

intRate=5;

Interest=0;

transaction=0;

}

double getBalance() //accessor

{

return balance;

}

void MakeDeposit(double amount) //mutator

{

balance=balance+amount;

transaction++;

}

void Widthdraw(double amount)

{

if(amount>balance)

cout<<" Sorry ! Balance is not sufficient !";

else

{

cout<<" Collect Your Amount: "<<amount;

balance=balance-amount;

transaction++;

}  

}

double CalcInterest()

{

float intAmount=(balance*intRate)/(float)(365*100);

cout<<" Today's Interest is :"<<intAmount;

Interest=Interest+intAmount;

balance=balance+intAmount;

return Interest;

}

int getTransaction() //mutator

{

return transaction; //Accessors and mutators are the method of class which use to access and update respectively private members of class.

}

};

int main()

{

cout<<" 1.Make Deposit 2.Withdraw 3.Balance Enquiry 4.Calculate Interest 5.Total Transaction 6.Exit.";

Bank b; //declare object of class Bank

double amount,intAmount;

int option;

while(1)

{

cout<<" Select Your option : ";

cin>>option;

switch(option)

{

case 1:

cout<<" Enter Amount to Deposit : ";

cin>>amount;

b.MakeDeposit(amount);

cout<<" Your Total Balance : "<<b.getBalance();

break;

case 2:

cout<<" Enter Amount to Widthdraw : ";

cin>>amount;

b.Widthdraw(amount);

break;

case 3 :

cout<<" Your Current Balance :"<<b.getBalance();

break;

case 4 :

cout<<" Total Ineterest for current Period : "<<b.CalcInterest();

break;

case 5:

cout<<" Your Total Transtaction current Period : "<<b.getTransaction();

break;

case 6:

return 0;

}

  

}

}

/*OUTPUT

1.Make Deposit

2.Withdraw

3.Balance Enquiry

4.Calculate Interest

5.Total Transaction

6.Exit.

Select Your option : 4

Today's Interest is :0

Total Ineterest for current Period : 0

Select Your option : 5

Your Total Transtaction current Period : 0

Select Your option : 2

Enter Amount to Widthdraw : 1

Sorry ! Balance is not sufficient !

Select Your option : 3

Your Current Balance :0

Select Your option : 1

Enter Amount to Deposit : 500

Your Total Balance : 500

Select Your option : 4

Today's Interest is :0.0684932

Total Ineterest for current Period : 0.0684932

Select Your option : 3

Your Current Balance :500.068

Select Your option : 2

Enter Amount to Widthdraw : 200

Collect Your Amount: 200

Select Your option : 5

Your Total Transtaction current Period : 2

Select Your option : 6

--------------------------------

Process exited after 53.54 seconds with return value 0

Press any key to continue . . .

*/