CJCoding With Joseph
15free / daySign inCreate account

Decompose a Price Calculation

Split a calculation into focused functions, each doing one job. Write two functions:

1) double subtotal(double price, int qty) that returns price * qty.
2) double withTax(double amount, double taxPercent) that returns amount plus taxPercent percent of tax (for example withTax(30, 10) returns 33).

The hidden test combines them: withTax(subtotal(price, qty), taxPercent). Just write the two functions.

Do NOT write a main function.

Expected Output:

33.00
10.80

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Modular Programming
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.