Problem of the Day
Wednesday, January 7, 2026
Problem:
A bagel shop, when selling bagels to its customers, will pack them in a box when possible, where 12 bagels fill a box. The shop only uses a box if it can be completely filled with 12 bagels. Any bagels for a customer that don't fit in a filled box are placed in a bag. So, an order for 27 bagels would be delivered in two boxes (each containing 12 bagels), and a bag containing three additional bagels.
Consider the following method, which identifies how many boxes will be needed for an order.
public static int boxesNeeded(int bagelsOrdered)
{
return /* missing code */
}
Which of the following could be used to replace /* missing code */ so that the method will work as intended?
return 12 % bagelsOrdered;return 12 / bagelsOrdered;return bagelsOrdered / 12;return bagelsOrdered % 12;
The correct answer is c. The variable bagelsOrdered and the value 12 are both int values, so an integer, "whole-number" division is performed, correctly identifying the number of boxes needed. Any additional bagels beyond those that fit in the boxes will have to go into a bag.