You are on page 1of 2

Program no_____

Aim-To create a class bank


#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
class bank{
char name[20],typeofaccount[10];
unsigned int accountnumber;
float balance;
public:
void initialize()
{cout<<"enter your name";
gets(name);
cout<<"Enter the account number";
cin>>accountnumber;
cout<<"account type";
gets(typeofaccount);
if((strcmp(typeofaccount,"s")||strcmp(typeofaccount,"c"))==1)
{cout<<"enter your current account balance";
cin>>balance;
}
}
void deposit()
{float d;
cout<<"enter the amount to be deposited";
cin>>d;
balance=balance+d;
}
void withdraw()
{float w;
if(balance>=1000)
{cout<<"enter the amount you want to withdraw=";
cin>>w;
balance=balance-w;
}
else
{cout<<"not enough balance";
}
}
void display()
{cout<<'\n';
puts(name);
cout<<'\n'<<typeofaccount;
cout<<'\n'<<accountnumber;
cout<<'\n'<<balance;
}
};
void main()
{clrscr();
bank b;
int n;
b.initialize();
cout<<"enter your choice";
cout<<"\n1.to withdraw money\n2.to deposit";
cin>>n;
if(n==1)
{b.withdraw();}
if(n==2)
{b.deposit();}
b.display();
getch();}

You might also like