Back to Challenge Set 17

Code Challenge: Receipt Total

Difficulty  

divider

The Brief

What they asked for
Three methods, one receipt. One works out the subtotal
from a price and quantity, one adds tax, one formats a
line for printing. I want them to hand values to each
other rather than each printing their own bit.

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


Notes

  • This is about methods working together. Two of the three must return values, not print.
  • Only one method should contain a Console.WriteLine. Decide which, and say why.
  • Call them nested — one method's return value as another's argument — at least once.
  • Money formatting is a display job. :F2 belongs in the method that displays.
  • Lining the amounts up in a column needs a tool this course has not taught, so the sample uses = instead.

Sample Output

Sample Output
Widget x3 @ $4.50 = $13.50
Tax (8%) = $1.08
TOTAL = $14.58

3 × 4.50 is 13.50, and 8% of that is 1.08.


Submit

Your requirements list and your program file, named cc-receipt-total.

Commence Challenge