/*write a c++ program to define a class to represent a bank account which include following member
data member:-
1)name
2)Account number
3)type of account
4)bal.amt
member function:
a.to assign initial value
b.to deposit an account
c.to withraw an account
d.to display name,account number and balance
*/
#include<conio.h>
#include<iostream.h>
#include<string.h>
int w_amt;
class bank
{
public:int acc_no,bal;
char type[30],name[30];
public:void assign()
{
strcpy(name,"amar");
acc_no=111;
strcpy(type,"saving");
bal=12000;
}
void deposit()
{
int amt;
cout<<"\nenter the amount which you want to deposit:-";
cin>>amt;
bal=bal+amt;
}
void withdraw()
{
cout<<"\nenter how much money you want to withdraw";
cin>>w_amt;
}
void display()
{
cout<<"\nname:-"<<name
<<"\naccount number:-"<<acc_no
<<"\ntype of account:-"<<type
<<"\nbalance amount:-"<<bal;
}
};
int main()
{
bank b;
clrscr();
b.assign();
b.deposit();
b.withdraw();
if(w_amt>12000)
{
cout<<"you do not have that much balance try again";
}
else
b.bal=b.bal-w_amt;
b.display();
getch();
return 0;
}
/*
enter the amount which you want to deposit:-1200
enter how much money you want to withdraw200
name:-amar
account number:-111
type of account:-saving
balance amount:-13000
*/
data member:-
1)name
2)Account number
3)type of account
4)bal.amt
member function:
a.to assign initial value
b.to deposit an account
c.to withraw an account
d.to display name,account number and balance
*/
#include<conio.h>
#include<iostream.h>
#include<string.h>
int w_amt;
class bank
{
public:int acc_no,bal;
char type[30],name[30];
public:void assign()
{
strcpy(name,"amar");
acc_no=111;
strcpy(type,"saving");
bal=12000;
}
void deposit()
{
int amt;
cout<<"\nenter the amount which you want to deposit:-";
cin>>amt;
bal=bal+amt;
}
void withdraw()
{
cout<<"\nenter how much money you want to withdraw";
cin>>w_amt;
}
void display()
{
cout<<"\nname:-"<<name
<<"\naccount number:-"<<acc_no
<<"\ntype of account:-"<<type
<<"\nbalance amount:-"<<bal;
}
};
int main()
{
bank b;
clrscr();
b.assign();
b.deposit();
b.withdraw();
if(w_amt>12000)
{
cout<<"you do not have that much balance try again";
}
else
b.bal=b.bal-w_amt;
b.display();
getch();
return 0;
}
/*
enter the amount which you want to deposit:-1200
enter how much money you want to withdraw200
name:-amar
account number:-111
type of account:-saving
balance amount:-13000
*/
No comments:
Post a Comment