0% found this document useful (0 votes)
9 views

implementation of Classes, Objects and Member Functions

This C++ code defines a class called "account" with member variables such as name, account number, account type, and balance. It includes member functions to initialize a new account, deposit and withdraw amounts, and display account details. The main function creates an account object, calls the member functions to deposit and withdraw amounts, and finally displays the account details.

Uploaded by

Amar Rajput
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

implementation of Classes, Objects and Member Functions

This C++ code defines a class called "account" with member variables such as name, account number, account type, and balance. It includes member functions to initialize a new account, deposit and withdraw amounts, and display account details. The main function creates an account object, calls the member functions to deposit and withdraw amounts, and finally displays the account details.

Uploaded by

Amar Rajput
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

//implementation of classes,objects and member functions

#include<iostream.h> #include<conio.h> #include<stdio.h> class account { char name[31]; int acc_no; char act; float balance; public: void initial() { cout<<"Name:"; gets(name); cout<<"Account Number:"; cin>>acc_no; cout<<"Account type saving/current(s/c):"; cin>>act; cout<<"Balance:"; cin>>balance; cout<<endl; getch(); } void deposit(float amt); void withdraw(float amt); void display(); int getacno() { } }; return acc_no;

void account::deposit(float amt) { balance+=amt; cout<<"\n amount deposited\n"; getch(); } void account::withdraw(float amt) { if(balance-amt>=1000) { balance-=amt;

cout<<"\n amount withdrawn \n"; getch(); } else { cout<<"Minimum balance has to be Rs.1000/-"<<endl;

cout<<"You can withdraw only"<<balance-1000 <<"Rupees"<<endl; cout<<"\n Press a key to continue...\n"; getch(); } } void account::display() { cout<<"Account Number:"<<acc_no<<endl; cout<<"Account Holder:"; puts(name); cout<<"\n Account type:"<<act<<endl; cout<<"Balance(Rs.):"<<balance<<endl; getch(); } void main() { account a; int amtd,amtw; clrscr();

a.initial(); cout<<"Enter the amount to be deposited:"; cin>>amtd; a.deposit(amtd); cout<<"Enter the amount to be withdrawn:"; cin>>amtw; a.withdraw(amtw); a.display(); a.getacno(); getch(); }

OUTPUT

Name:chal_hut Account Number:5 Account type saving/current(s/c):s Balance:0 Enter the amount to be deposited:55 amount deposited 55 Enter the amount to be withdrawn:55 amount withdrawn 55 Minimum balance has to be Rs.1000/You can withdraw only 0 rs Press a key to continue...

You might also like