[Math] How to solve simple programming problem with strange math question

recreational-mathematics

Here is the question:

A cookie recipe calls for the following ingredients:

  • 1.5 cups of sugar
  • 1 cup of butter
  • 2.75 cups of flour

The recipe produces 48 cookies with this amount of the ingredients.
Write a program that asks the user how many cookies he or she wants to
make, and then displays the number of cups of each ingredient needed
for the specified number of cookies.

I already saw the answer, and it only confused me more. I need someone to explain to me how we go about figuring out how many cups of sugar is needed if, for example, the user wants to bake 50 cookies.

EDIT: I'm mainly interested in the thought process used to solve the math portion of this problem.

Best Answer

First of all, scale down the various ingredient requirements from a 48-cookie batch size to an individual cookie size. This is done by dividing your three amounts {1.5, 1, 2.75} by 48, giving {1/32, 1/48, 11/192}. Then all one has to do is multiply the required cookie batch size by each of these individual amounts. At least that is how I'd do it.

Related Question