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
write a program to find 2 power of a 5digit number with out using big int and exponent ?
if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?
What is the real life example of polymorphism?
What is the real time example of inheritance?
Prepare me a program for the animation of train
Why do we use class?
What does and I oop mean?
Where is pseudocode used?
Get me a number puzzle game-program
Why is polymorphism used?
Can private class be inherited?
What is encapsulation process?
write a program using c++ to implement single contiguous memory mangement techniques.display the content of the main memory after yhe allocation of jobs and percentage of the wastage of the main memory
What does <> mean pseudocode?
What is super in oop?