Formulate a bottle-filling problem

Write an algorithm for filling a water bottle with cups of water. The algorithm should determine how many cupfuls are needed and explain how to pour the water into the bottle.

Choose the bottle and cup capacities, then create a formulation before writing pseudocode. State:

  1. the inputs and required outputs;
  2. the state that changes while the bottle is being filled;
  3. the rule for each pour, including the final pour; and
  4. the stopping condition and any assumptions needed to prevent overflow and ensure that the algorithm stops.

Use your model to write pseudocode. Give the final number of cupfuls for the capacities you chose.

Decide what happens when the remaining space in the bottle is smaller than the cup capacity.