Create a class Customer with following details
Class
Method and Variables
Description
Customer
User defined class
int
cid
Private integer variable to denote customer id
float
balance
Private float variable to denote customer balance
int
bid
Private integer variable to denote branch id
static int
countbr
Public static integer variable and it should be initialized as zero
void get()
Public get method get the input from users such as cid, balance and bid
void find()
Public find method to find and update the number of customer having account at branch number 22 in countbr variable
static void dispalay()
This public static method display the value of the variable countbr
int main()
{
int n;
………..
………….
return 0
}
#include <iostream>
#include <string>
using namespace std;
class Customer{
private:
//Private integer variable to denote customer id
int cid;
//Private float variable to denote customer balance
float balance;
//Private integer variable to denote branch id
int bid;
public:
//Public static integer variable and it should be initialized as zero
static int countbr;
//Public get method get the input from users such as cid, balance and bid
void get(){
cout<<"Enter customer id: ";
cin>>cid;
cout<<"Enter customer balance: ";
cin>>balance;
cout<<"Enter customer branch id: ";
cin>>bid;
countbr++;
}
//Public find method to find and update the number of customer having account at branch number 22 in countbr variable
void find(){
if(bid==22){
countbr=0;
}
}
//This public static method display the value of the variable countbr
static void dispalay(){
cout<<"countbr: "<<countbr<<endl;
}
//Constructor
Customer (){
countbr=0;
}
//destructor
~Customer (){}
};
int Customer::countbr=0;
//The start point of the program
int main (){
Customer allCustomers[30];
for(int i=0;i<30;i++){
allCustomers[i].get();
allCustomers[i].dispalay();
cout<<"\nCall function find()\n";
allCustomers[i].find();
allCustomers[i].dispalay();
cout<<"\n";
}
//delay
system("pause");
return 0;
}
Comments
Leave a comment