Back to Challenge Set 1

Code Challenge: Pizza Split

Difficulty  

divider

The Brief

What they asked for
We order pizza for club night. Everybody gets the same
number of slices, and whatever is left over goes in the
fridge for whoever stays late. I never know how many to
order, so I just want to type in what I bought and how
many people showed up.

Write your requirements list before you write any code. Input, calculate, output, and anything you had to decide for yourself.


Notes

  • The number of pizzas and the number of slices per pizza are two different things. Decide whether you ask for both.
  • Nobody eats part of a slice. Your answer for slices-per-person has to be a whole number.
  • Activity 1.6 has both halves of that — the remainder, and the whole number left after you remove it.

Where to Start

Only one-star challenges have this section. If you already know how to begin, skip it — and when you move up to two stars, working out the order yourself is part of the job.

  1. Get the numbers you need, using fixed values or input.
  2. Work out how many whole slices each person gets.
  3. Work out how many are left over. Activity 1.6 has both operators you need.
  4. Print both, with labels.

Sample Output

Sample Output
Pizzas: 3
Slices per pizza: 8
People: 7
Total slices: 24
Each person gets: 3
Left for the fridge: 3

Your program can use fixed values or ask for them. Either is fine at this point in the set.


Submit

Your requirements list and your program file, named cc-pizza-split.

Commence Challenge