← Back to Modular Programming
Question 181
Decompose a Price Calculation
Decompose a Price Calculation
Split a calculation into focused functions, each doing one job. Write two functions: 1) doublesubtotal(double price, int qty)that returns price * qty. 2) doublewithTax(double amount, double taxPercent)that returns amount plus taxPercent percent of tax (for examplewithTax(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
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.