Answer to Question #215647 in C++ for Taj Wali

Question #215647
Q. Write a class Bank that has the following data members.
Account Holder name (ah_name[])
Account number (ac_number)
Must unique, system generates automatically, and must starting from 100 (Hints: Use another static variable and assign that variable to ac_number)

Balance in the account (ac_balance)



The class has the following member functions.

A constructor to initialize the data members.
Input() to takes name from the user.
Deposit(parameter) to deposits balance in the account.
Must accept parameter (The amount to deposit).
Withdraw(parameter) to withdraws balance after checking.
Must accept parameter (The amount to withdraw).
Display() to show the name, account number, and balance.
1
Expert's answer
2021-07-12T03:09:56-0400
#include<iostream>
#include<bits/stdc++.h>
using namespace std;

class Bank{
	public:
		char ah_name[100];
		int ac_number;
		int ac_balance;
		
		void input()
		{
			cout<<"Enter Account holder name : ";
			cin>>ah_name;
			cout<<"Enter account number : ";
			cin>>ac_number;
			cout<<"Enter Account Balance : ";
			cin>>ac_balance;
			cout<<endl;
		}
		
		void deposit(int n)
		{
			ac_balance += n;
			cout<<"Money deposited successfully"<<endl<<endl;
		}
		
		void withraw(int n)
		{
			if(n <= ac_balance)
			{
				ac_balance -= n;
				cout<<"Money Withdraw successfully"<<endl<<endl;
			}
			else{
				cout<<"Less current balance"<<endl<<endl;
			}
		}
		
		void display()
		{
			cout<<"Account holder name : "<<ah_name<<endl;
			cout<<"Account number : "<<ac_number<<endl;
			cout<<"Account balance : "<<ac_balance<<endl;
		}
};

int main()
{
	Bank b;
	b.input();
	cout<<endl<<endl<<"Account User details "<<endl<<"--------------------------------"<<endl;
	b.display();
	cout<<endl<<endl;
	cout<<"Enter amount u want to deposit : ";
	int n;
	cin>>n;
	b.deposit(n);
	cout<<endl<<endl;
	b.display();
	
	cout<<endl<<endl;
	cout<<"Enter amount u want to withdraw : ";
	int m;
	cin>>m;
	b.withraw(m);
	cout<<endl<<endl;
	b.display();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS