← Back to Printing
Question 12
Receipt Formatting
Receipt Formatting
Create three float variables: price1 = 12.99f, price2 = 8.50f, and price3 = 15.25f. Calculate the total and use printf to create a formatted receipt (see Expected Output).
Each price should be displayed with exactly 2 decimal places using %.2f. Calculate the total by adding all three prices together.Expected Output:
Item 1: $12.99 Item 2: $8.50 Item 3: $15.25 Total: $36.74
= newline. No newline after the last line.
Hints3 available
Sign in to use hintsTopics:
Printing
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.