Question

each of the data attributes. b. Accessor and mutator methods for each data attribute. An ..str method that returns a string i
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Ans. program code :

#include<iostream>
#include<stdlib.h>
using namespace std;
class bank
{
int ac,bal;
static int reset_t;
float balance, amount, shorta;
public:
// declaring methods
void deposit();
void withdraw();
void chkbalance();
void interestRate();
int menu();
};
int bank::reset_t=0;
//defining the methods
void bank::deposit()
{
cout<<"\n Enter Account Number:";
cin>>ac;
if(ac==1001)
{
cout<<"\nEnter Amount you want to Deposit:";
cin>>amount;
balance=balance+amount;
cout<<"\n\nMessage: You have successfully deposited Rs."<<amount<<" into your account.\n\nYour Current Balance is:"<<balance<<"\n\n";
reset_t++;
}
else
{
cout<<"You have entered invalid account number";
}
}
void bank::withdraw()
{
cout<<"Enter Account Number:";
cin>>ac;
if(ac==1001)
{
cout<<"Enter Amount you want to Withdraw:";
cin>>amount;
if(amount>balance)
{
shorta=amount-balance;
cout<<"\n\nYou cannot withdraw Rs."<<amount<<" as your account balance is Rs."<<balance<<"\n\nYou are short of Rs."<<shorta;
}
else
{
balance=balance-amount;
cout<<"You have Withdrawn Rs."<<amount<<" Successfully\n\n Your account balance is:"<<balance<<"\n\n";
}
}
else
{
cout<<"You have entered invalid account number";
}
}
void bank::chkbalance()
{
cout<<"Enter Account Number:";
cin>>ac;
if(reset_t==0)
{
balance=0;
}
if(ac==1001)
{
cout<<"Your Account balance is Rs."<<balance<<"\n\n";
}
else
{
cout<<"Account Doesn't Exist!!";
}
}
void bank::interestRate()
{
   cout<<"Enter Account Number:";
cin>>ac;
if(reset_t==0)
{
balance=0;
}
if(ac==1001)
{
cout<<"Your Account balance is Rs."<<2*balance<<"\n\n";
}
else
{
cout<<"Account Doesn't Exist!!";
}
}

int main()
{
bank ob;
int ch,value;
//showing the type of account
cout<<"\n enter the type of account";
cout<<"\n 1: savings";
cout<<"\n 2: checking account";
cout<<"\n 3: money market account";
cout<<"\n";
cin>>value;
  
do {
//dispalying menu to user
cout<<"\n\n\n1.Deposit\n2.Withdraw\n3.Balance Enquiry\n4.calculate interest\n5.Exit\n\n";
ch=ob.menu();
switch(ch)
{
case 1:ob.deposit(); // case for depositing amount
break;
case 2:ob.withdraw(); //case for withdrawing amount
break;
case 3:ob.chkbalance(); //case to check balance
break;
case 4: ob.interestRate(); //case to find teh interest rate
break;
case 5: exit(1);
default:cout<<"Invalid Choice!!"; //showing default message to user
}
}while(1);
}

int bank::menu()
{
int ch;
cout<<"\nEnter your Choice:";
cin>>ch;
return ch;
}

output: enter the type of account 1: savings 2: checking account 3: money market account Deposit 2.Withdraw 3.Balance Enquiry 4.calcu

media%2F898%2F898d4c47-7140-4f42-8319-67

media%2F8fe%2F8fec8b85-b3bf-47d6-b16b-f6

media%2Fcee%2Fcee56a3c-2dbe-4c10-a4d6-02

Add a comment
Know the answer?
Add Answer to:
each of the data attributes. b. Accessor and mutator methods for each data attribute. An ..str method that returns a string indicating the state of the object 3. Look at the following description...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment...

    Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of 100 accounts. Use an array of pointers to objects for this. However, your...

  • Programming Assignment 5: UML Diagram Objectives: After successfully completing this assignment, students will practice Object Oriented...

    Programming Assignment 5: UML Diagram Objectives: After successfully completing this assignment, students will practice Object Oriented design by creating an UML diagram for a Java program. Program Statement: Bank System You were asked to create a simple UML diagram for a bank system. Each bank has a specific identification number, a name, and a location that needs to be stored. Tellers serve customers’ loans, checking and savings accounts. The bank must know each tellers’ name and identification number for record...

  • Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the...

    Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT