Você está na página 1de 4

C++ : PRACTICAL NO.

1
( Array of class objects – program 1 )
sss
\n PROBLEM STATEMENT:
Declare a class to represent the bank account of a customer with the following
data members :
- Name of the depositor
- Account Number
- Type of account ( S for savings and C for current )
- Balance amount.
The class also contains the following member functions :
(a) to initialize data members
(b) to deposit money
(c) to withdraw of money after checking for minimum balance ( minimum
balance is Rs. 1000 )
(d) to display the data members
Write a complete C++ program that is capable of manipulating the accounts of 10
account holders using this class.

SOURCE CODE:
#include <iostream>
#define SIZE 3
using namespace std;
class bank {
char name[20];
char type;
double balance;
public: void getdata() {
cout << "Enter Name:-";
cin>>name;
cout << "Enter account type:-";
cin >> type;
cout << "Enter balance:-";
cin >> balance;
}
void showdata() {
cout << "\nName:-" << name;
cout << "\nAccount Type ";
if (type == 'S') {
cout << "Savings\n";
}
else
cout << "Current\n";
cout << "Account Balance " << balance<<endl;
}
void deposite(){
double add;
cout<<"\nEnter the amount to be deposited ";
cin>>add;
balance+=add;
}
void withdraw(){
if(balance<=1000){
cout<<"\n Sorry the account balance is less that the minimum
required balance "<<endl;
return;
}
double out;
cout<<"\n Enter amount to withdraw ";
cin>>out;
balance-=out;
}
};
bank user[SIZE];
int main(){
while(1){
int input;
int user_no;
cout<<"\nChoose one of the following options:-";
cout<<"\n1)Enter Data";
cout<<"\n2)Add money ";
cout<<"\n3)Withdraw money ";
cout<<"\n4)Show details ";
cout<<"\n5)Exit ";
cout<<"\nINPUT:-";
cin>>input;
cout<<"\nEnter user number 1-"<<SIZE<<" ";
cin>>user_no;
user_no--;
if(input==1){
user[user_no].getdata();
}
else if(input==2){
user[user_no].deposite();
}
else if(input==3){
user[user_no].withdraw();
}
else if(input==4){
user[user_no].showdata();
}
else{
cout<<"\nTHNAKS FOR USING OUR SERVICES\n";
return 0;
}
}
}
OUTPUT SCREEN:

Você também pode gostar