Answer to Question #291519 in C++ for Abdullah

Question #291519

Suppose you have to enter five customers in a bank. The bank counter comprises of three service desk so three rows and three columns were made. Write a C++ program to provide service for customers according to row and column. First customer will stand in the first row first column, then the next customer in the first row second column and so on. Create a function which takes total number of customers as input as an argument and display the seating plan using another function.



1
Expert's answer
2022-01-28T07:59:27-0500
#include<iostream>
#include<vector>

using namespace std;

//Seating plan function 
void SeatingPlan(vector<vector<char> > desks)
{
	cout<<"\nSeatingPlan:\n";
	cout<<"Col:   1  2  3\n";
	for(int i=0;i<3;i++)
	{
		cout<<"Row "<<i+1<<": ";
		for(int j=0;j<3;j++)
		{
			cout<<desks[i][j]<<"  ";
		}
		cout<<endl;
	}
}

void Customers(vector<vector<char> >& desks,int num)
{
	if(num>9||num<0)
	{
		cout<<"Incorrect number of customers!";
		return;
	}
	int counter=0;
	for(int i=0;i<3;i++)
	{
		if(counter>num)
			break;
		for(int j=0;j<3;j++)
		{
			if(counter<num)
			{
				desks[i][j]='X';
				counter++;
			}
			else
				break;
			
		}
	}
}

int main()
{
	vector<vector<char> > d(3,vector<char>(3,'0'));
	int n;
	SeatingPlan(d);
	cout<<"Please, enter the number of customers: ";
	cin>>n;
	Customers(d,n);	
	SeatingPlan(d);
}

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