google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: Write Cpp program to represent bank account using member function

Monday, February 23, 2015

Write Cpp program to represent bank account using member function

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 withdraw 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,"Vijay");
       acc_no=111;
       strcpy(type,"saving");
       bal=12000;
       }
       void deposit()
       {
       int amt;
       cout<<"\n Enter the amount which you want to deposit:-";
       cin>>amt;
       bal=bal+amt;
       }
       void withdraw()
       {
       cout<<"\n Enter how much money you want to withdraw";
       cin>>w_amt;
       }
       void display()
       {
       cout<<"\n Name:-"<<name
       <<"\n Account number:-"<<acc_no
       <<"\n Type of account:-"<<type
       <<"\n Balance 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;
}


==============================================

OUTPUT

Enter the amount which you want to deposit:-1200
Enter how much money you want to withdraw200
Name:-Vijay
Account number:-111
Type of account:-saving
Balance amount:-13000

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...