Decompose a Price Calculation
mediumQuestion 181Split 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, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
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.