Back to Set 1

Code Challenge: Recipe Scaler

Difficulty  

divider

The Brief

What they asked for
This recipe serves four and I am cooking for eleven. Take
the four-person amounts and tell me what I actually need.

Write your requirements list before you write any code. What goes in, what gets worked out, what comes out, and every question the brief did not answer.


Notes

  • Pick a real recipe with at least three ingredients and put its four-person amounts in your program as variables.
  • One number goes in and several come out. Every amount is worked out from the same scale factor, which should be a variable of its own.
  • 5.5 eggs is a correct answer and a silly one. The brief does not say what to do about it, so you decide, and say so.
  • Change the recipe to serve six instead of four. If that is a one-line change you named your variables well.

Sample Output

Sample Output
How many people? 11 [Enter]
For 11 people:
Flour: 550 g
Butter: 275 g
Sugar: 165 g
Eggs: 5.5

Your recipe will be different. Test 4 — the output should be the original amounts exactly.


Submit

Your requirements list and your program folder, named cc-recipe-scaler.

Commence Challenge