This program complie and run using turbo C++
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class Add
{
private:
char name[20];
int acc_no;
int ph_no;
char addr[30];
int balance;
int with;
int depo;
int i;
clrscr();
public:
void input()
{
cout<<"Enter customer name: "<<endl;
cin>>name;
cout<<"Enter customer account number: "<<endl;
cin>>acc_no;
cout<<"Enter customer address: "<<endl;
cin>>addr;
cout<<"Enter customer phone number: "<<endl;
cin>>ph_no;
cout<<"Enter customer opening balance: "<<endl;
cin>>balance;
}
void deposit()
{
cout<<"Enter how much you want to deposit: "<<endl;
cin>>depo;
balance=balance+depo;
cout<<"Current balance is: "<<balance<<endl;
}
void withdraw()
{
cout<<"Enter how much you want to withdraw: "<<endl;
cin>>with;
if(with>balance)
{
cout<<"Sorry!You do not have enough balance in your account. "<<endl;
cout<<"Current Balance is: "<<balance<<endl;
}
else
{
balance=balance-with;
cout<<"Current balance is: "<<balance<<endl;
}
}
void show()
{
cout<<"Acc_no: "<<"\t";
cout<<"Name: "<<"\t";
cout<<"Balance: "<<"\t";
cout<<"Addr: "<<"\t";
cout<<"Ph_no: "<<"\n";
}
void print()
{
cout<<acc_no<<"\t"<<"\t";
cout<<name<<"\t";
cout<<balance<<"\t"<<"\t";
cout<<addr<<"\t";
cout<<ph_no<<"\t"<<"\n";
}
void enquire()
{
cout<<"Current Balance: "<<balance;
cout<<endl;
}
};
void main()
{
Add a[100];
int s,i=0,p,n,l=1;
a[l].input();
while(1)
{
clrscr();
cout<< " //Main menu//"<<endl;
cout<<"Press 1 for deposit "<<endl;
cout<<"press 2 for withdraw "<<endl;
cout<<"Press 3 for cheak a account details "<<endl;
cout<<"Press 4 to open a new account "<<endl;
cout<<"Press 5 for Balance Enquire "<<endl;
cout<<"Press 6 for cheak all customer details"<<endl;
cout<<"Press 7 to exit "<<endl;
cin>>s;
switch(s)
{
case 1:
cout<<"Enter the serial number"<<endl;
cin>>p;
for(i=0;i<100;i++)
{
if((i+1)==p)
a[i].deposit();
}
break;
case 2:
cout<<"Enter the serial number"<<endl;
cin>>p;
for(i=0;i<100;i++)
{
if((i+1)==p)
a[i].withdraw();
}
break;
case 3:
cout<<"Enter the Serial number"<<endl;
cin>>p;
for(i=0;i<100;i++)
{
if((i+1)==p)
{
a[i].show();
a[i].print();
}
}
break;
case 4:
a[l].input();
l++;
break;
case 5:
cout<<"Enter the Serial number"<<endl;
cin>>p;
for(i=0;i<100;i++)
{
if((i+1)==p)
a[i].enquire();
}
break;
case 6:
a[0].show();
for(i=0;i<l;i++)
{
a[i].print();
}
break;
case 7:
exit(0);
default:
cout<<"Please cheak your entry";
}
getch();
}
}
No comments:
Post a Comment