Receipt to Any Stream
mediumQuestion 637Write a function void receipt(ostream& out, const vector<pair<string, double>>& items) that writes one line per item — the item name, a single space, and the price with exactly 2 decimal places — and then a final line Total: followed by the sum of all prices, also with 2 decimals. Every line ends with a newline. Use fixed and setprecision(2). Write everything to out.
With no items only the line Total: 0.00 is printed.
Do NOT write a main function.
Expected output
tea 2.50 cake 7.00 Total: 9.50 water 1.00 Total: 1.00 Total: 0.00
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Streamsostream
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.