I am trying to check the customers request against the volume remaining in the tank. If the request is greater, I need to instruct the customer to move to the next tank. But I am having problems. The tank is set to store 100 gallons. On the 1st request, I ask for more than 100 gallons, and instead of moving to the next pump it I am told to try another station.

The second problem is if the 1st customer is dispensed an amount less than the 100 gallon capacity, the 2nd customer can also be issued an amount less than the 100 gallons, instead of being moved to the next pump.

Any help will be appreciated.

if (listOfPumps[pumpSelection]->checkRorP(grade, quantity)== true)
					{
						listOfPumps[pumpSelection]->dispense(grade, quantity);
						numOfCustomers--;
						listOfPumps[pumpSelection]->getVolume(grade);
					} // end if check == true
					///////////////////////////////////////////////////////
					//////////////////////////////////////////////////////
					
	               ////////////////////////////////////////////////////////////////
					else // checkRorP == false
					{
						int nextPump = pumpSelection%5 + 1 ;
						while (nextPump != pumpSelection)
						{
							if (listOfPumps[nextPump]->checkRorP(grade, quantity)==true)
							{
								listOfPumps[nextPump]->dispense(grade, quantity);
								numOfCustomers--;	
								/*
								cout << "\nThe amount left in tank is " << 
								listOfPumps[nextPump]->getRegVolume() << endl;	
								*/
								listOfPumps[nextPump]->getVolume(grade);
								break; 
							}  // end if
							else
								nextPump = nextPump%5 + 1;
						}
						if (nextPump == pumpSelection)
						{
							cout << "Sorry, we cannot service you. Please try another gas station. Sorry for the inconvenience\n" ;
							numOfCustomers--;
						}

					}

FORMAT!!!! How do you expect us to read that?!?! Use the PREVIEW button and if you don't like what you see, neither will we -- fix it!

If your pumps hold 100 gallons and you ask for more than 100 gallons, the pumps at that station can't handle the requests. Seems to me going to another station with greater pump capacity is the answer...

Unless you didn't explain your task fully.

Ok I understand if the request is over 100 gallons, none of the pumps can dispense. But if there is an amount less than 100 gallons in the tank, and a request is made for an amount greater than that, I want to instruct the user to move to the next pump. If the next pump can not meet the request, then we try all pumps before we send the customer to the next station.

Thank you for your assistance.

if (listOfPumps[pumpSelection]->checkRorP(grade, quantity)== true)
{
	listOfPumps[pumpSelection]->dispense(grade, quantity);
	numOfCustomers--;
	listOfPumps[pumpSelection]->getVolume(grade);
} // end if check == true
					
else // checkRorP == false
{
	int nextPump = pumpSelection%5 + 1 ;
	while (nextPump != pumpSelection)
	{
		if (listOfPumps[nextPump]->checkRorP(grade, quantity)==true)
		{
			listOfPumps[nextPump]->dispense(grade, quantity);
			numOfCustomers--;	
			listOfPumps[nextPump]->getVolume(grade);
			break; 
		}  // end if
		else
		nextPump = nextPump%5 + 1;
	}
		if (nextPump == pumpSelection)
		{
			cout << "Sorry, we cannot service  you. Please try 
                        another gas station." << endl;
		        numOfCustomers--;
		}

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.