In: Computer Science
A central distributes lime to different branch warehouses. They have a loading dock where sacks of lime of between 3000 and 9000 kg are arriving, with variable weights depending on the production circumstances. The company has a fleet of trucks with load capacities of between 18,000 and 28,000 Kgs.
It is intended to establish a protocol consisting of loading 20 trucks a day. Each truck wants to load a maximum of its capacity limit, having to leave if the next pull in the production line would exceed its capacity.
The company wants to develop a program that asks the operator in charge of loading the capacity of the truck and the weight of the bags, indicating whether to load the bag or dispatch the truck to start loading another.
Need help to make the code with python
choice = 'yes'
while(choice == 'yes'):
capacity = int(input('Enter the capacity of the
truck (18000 kg 28000 kg): '))
if not(18000<=capacity<=28000):
print("Invalid truck
capacity.")
break;
capacityLeft = capacity
while(True):
weight =
int(input('Enter weight of bag (3000 kg to 9000 kg): '))
if
capacityLeft-weight>=0:
capacityLeft -= weight
else:
break
print("Truck with capacity:", capacity, "loaded
with", capacity-capacityLeft, "kg lime, dispatched.")
choice = input("Do you want to load next truck?
yes/no")