Back to Challenge Set 16

Code Challenge: Tip Split

Difficulty  

divider

The Brief

What they asked for
Six of us go out and I always end up doing the math.
Bill, tip percent, how many people. Tell me what each
person owes. And round it up, nobody wants to hand over
four dollars and sixteen cents.

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


Notes

  • Three parameters, of two types. Decide their order and write it in your requirements list — you will get it wrong once otherwise.
  • Rounding up is not the same as rounding. :F2 rounds to the nearest cent, which is not what the brief asks. C# has Math.Ceiling, which rounds a double up to the next whole number; rounding up to the next cent means working in cents for a moment.
  • Watch Activity 1.6: 18 / 100 is 0 in C#.
  • If the rounded amounts add up to more than the bill, that is correct and worth showing in the output.

Sample Output

Sample Output
Bill: 98.40 Tip: 18% People: 6
Each person owes: $19.36
Collected: $116.16 (bill + tip was $116.11)

Everyone pays $19.36, which collects five cents more than the bill. That is the brief's rounding doing its job.


Submit

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

Commence Challenge