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


Please Help Members By Posting Answers For Below Questions

What is destructor oops?

824


Can destructor be overloaded?

785


hi all..i want to know oops concepts clearly can any1 explain??

1876


Why interface is used?

731


What is oops concept with example?

759


• What are the desirable attributes for memory managment?

1934


Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.

1951


What is polymorphism and example?

767


What is debug class?what is trace class? What differences are between them? With examples.

1840


What are the data types in oop?

808


What is polymorphism and types?

816


What is encapsulation oop?

784


Can you explain polymorphism?

802


What is the oops and benefits of oops programming?

722


What is interface? When and where is it used?

1865