Define a class to represent a bank account. Include the
following
members:
Data Members:
Name of the Depositor
Account Number
Type of Account
Balance amount in the account
Member Functions:
To assign the initial values.
To deposit an account.
To withdraw an amount after checking the balance.
Write a C++ main program to display account number,
name and
balance.
Answer Posted / arun
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<process.h>
// statement of customer detail....
struct acc_inf
{
char c_name[25];
int acc_no;
float balance;
char acc_type[7];
};
//statement of Class....
class bank
{
struct acc_inf x;
public:
void input();
void withdrawal(int,float);
void deposit(int,float);
void display(int);
};
// Statement of customer information...
void bank:: input()
{
cout<<endl<<" Enter the name of customer:- ";
gets(x.c_name);
cout<<" Enter account no:- ";
cin>>x.acc_no;
cout<<" Enter opening balance:- ";
cin>>x.balance;
cout<<" Enter acc_type (SAVING/CURRENT):- ";
gets(x.acc_type);
}
//Statement of Withdrawal function...
void bank::withdrawal(int ac,float money)
{
if(x.acc_no==ac)
{
if(x.balance-1000>=money)
x.balance -= money;
else
cout<<"Sorry, Insufficient Balance";
}
else
cout<<"** Sorry, Account no. is not found ** ";
}
// Statement of deposite function...
void bank::deposit(int ac,float money)
{
if(ac==x.acc_no)
x.balance += money;
else
cout<<"Sorry, Account no. is not found...";
}
// Statement of display Funtion...
void bank::display(int ac)
{
if(ac==x.acc_no)
{
cout<<"\nYour acc_no is: "<<x.acc_no;
cout<<"\nYour name is: ";
puts(x.c_name);
cout<<"\nYour current balance is: "<<x.balance;
cout<<"\nYour type of account is: "<<x.acc_type;
}
}
// statement of main Function....
main()
{
bank obj; //creating object for class bank
int ac;
float money;
int c;
clrscr();
do
{
clrscr();
cout<<endl<<"Welcome to Banking System";
cout<<"\n_________________________";
cout<<endl<<endl<<"1:Open New Account of the customer.";
cout<<endl<<"2:Withdrawal the money.";
cout<<endl<<"3:Deposit the money.";
cout<<endl<<"4:Display information about customer.";
cout<<endl<<"5:quit";
cout<<endl<<"what is your choice: ";
cin>>c;
switch(c)
{
case 1:
obj.input();
break;
case 2:
cout<<"Enter account no: ";
cin>>ac;
cout<<"enter the money to withdrawal: ";
cin>>money;
obj.withdrawal(ac,money);
break;
case 3:
cout<<"enter acc no: ";
cin>>ac;
cout<<"enter the money to deposit: ";
cin>>money;
obj.deposit(ac,money);
break;
case 4:
cout<<"enter acc no: ";
cin>>ac;
obj.display(ac);
break;
case 5:
exit(0);
default:
cout<<"Sorry, unable to process.. Try again later";
}
cout<<"Press Enter to continue...";
getch();
}while(c!=5);
return 0;
}
| Is This Answer Correct ? | 55 Yes | 25 No |
Post New Answer View All Answers
write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).
What is difference between data abstraction and encapsulation?
Whats is abstraction in oops?
what are the different types of qualifier in java?
Can we create object of interface?
What is encapsulation in ict?
how to get the oracle certification? send me the answer
Why do while loop is used?
Why is abstraction needed?
What is polymorphism explain?
What is encapsulation in oops?
What is pointer in oop?
What makes a language oop?
Can bst contain duplicates?
How is class defined?