Answer to Question #173453 in C++ for praveenkumar.b

Question #173453

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

}


1
Expert's answer
2021-03-25T03:03:41-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS