jituTechnology

jituTechnology

>3.1 Write a program to test this class for 10 customers. Make use of all three types of constructors (wherever appropriate)

>

/* define a class to represent a bank account. Include the following members:

Data Members:
i)                    Name of the account holder
ii)                   Account number
iii)                 Balance amount in the account
Member functions:
I)                    Open an account
II)                  Deposit and withdrawal money
III)                Display account information
Write a program to test this class for 10 customers. Make use of all three types of constructors (wherever appropriate)
Programmed by:
Name: Jitendra Yadav
roll.no. 10116
 Date: 27/07/2011          */
#include<iostream.h>
#include<conio.h>
#include <string.h>
#include <stdio.h>
class account
{   char name[20];
int accno;
int amt;
public:
account()
{
cout<<“Enter name: “;
gets(name);
cout<<“Enter account: “;
cin>>accno;
cout<<“Enter amount: “;
cin>>amt;
}
void deposit(int x)
{
amt=amt+x;
cout<<“deposite”<<amt<<endl;
}
void display()
{
cout<<“Name: “<<name<<endl;
cout<<“Acount number: “<<accno<<endl;
cout<<“Amount: “<<amt<<endl;
}
void withdraw(int y);
};
void account::withdraw(int y)
{
if (amt>100)
{
amt=amt-y;
cout<<“Withdrawl: “<<amt<<endl;
}
else
cout<<“Your amt is not sufficient: “;
}
int main()
{
account c[10];
int i;
for(i=0;i<10;i++)
{
c[i].display();
c[i].deposit(500);
c[i].withdraw(100);
}
getch();
return(0);
}
Output sample:
Enter name: Jitendra
Enter account: 789
Enter amount: 500
Enter name: Sudip
Enter account: 654
Enter amount: 900
Enter name: Sandeep
Enter account: 321
Enter amount: 564
Enter name: Kiran
Enter account: 989
Enter amount: 250
// similarly for all the other steps
Name: Jitendra
Amount: 500
Deposit: 1000
Withdrawal: 900
Name: Sudip
Account number: 654
Deposit: 1400
Withdrawal: 900
// similarly for all other steps

No comments yet.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

March 2024
S M T W T F S
 12
3456789
10111213141516
17181920212223
24252627282930
31