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 / pranay pushp

#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 ?    2 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which type does string inherit from?

616


What is abstraction in oops?

589


What polymorphism means?

624


What type of loop is a for loop?

682


what type of question are asked in thoughtworks pair programming round ?

1762






What is polymorphism what is it for and how is it used?

576


INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS?

1637


What is coupling in oops?

598


What are the three main types of variables?

600


What is advantage of inheritance?

690


i=20;k=0; for(j=1;k-i;k+=j<10?4:3) { cout<

1417


What is Difference Between Inheritance and creating object and getting data? means Class A extends B{ B.getMethod();} (OR) Class A{ b obj=new B(); obj.getMethod(); }

1988


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

1836


Why is polymorphism used?

586


Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.

2008