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 / akash jadhav

#include<iostream.h>
#include<conio.h>
#include<string.h>
class bank
{
char name[20];
int ano;
char atype[20];
float bal;
public:
void get(int no,char *n,char *t,float b)
{
strcpy(name,n);
ano=no;
strcpy(atype,t);
bal=b;
}
float deposit()
{
float amt;
cout<<“
Enter amount: “;
cin>>amt;
bal=bal+amt;
return bal;
}
float withdrw()
{
float amt;
cout<<“
How many Rupees withdraw: “;
cin>>amt;
bal=bal-amt;
return bal;
}
void disp()
{
cout<<“

Account number: “<<ano;
cout<<“

Name: “<<name;
cout<<“

Account type: “<<atype;
cout<<“

Deposit Amount: “<<deposit();
cout<<“

After Withdraw Amount balnace: “<<withdrw();
}
};
void main()
{
int n;
char nm[20],t[20];
float a;
bank bk;
clrscr();
cout<<“
Enter Account no.: “; cin>>n;
cout<<“
Enter Name: “; cin>>nm;
cout<<“
Enter account type: “; cin>>t;
cout<<“
Enter balance amount: “;cin>>a;
bk.get(n,nm,t,a);
bk.disp();
getch();
}

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the three main types of variables?

600


What is meant by multiple inheritance?

738


Write a program to sort the number with different sorts in one program ??

1920


Prepare me a program for the animation of train

2000


What is object-oriented programming? Webopedia definition

725






What exactly is polymorphism?

610


What is object in oops?

615


Explain the advantages of inheritance.

675


What is super in oop?

599


explain sub-type and sub class? atleast u have differ it into 4 points?

1836


What are the two different types of polymorphism?

672


What are objects in oop?

610


What is encapsulation oop?

578


What does sksksk mean in text slang?

1537


What are properties in oop?

610