← Back to Streams
Question 725
Receipts Numbered by a Static Counter
Receipts Numbered by a Static Counter
Receiptis written for you with a friend declaration. Defineostream& operator<<(ostream& os, const Receipt& r)below the class so each call prints one line:Receipt N for CUSTOMER: AMOUNTfollowed by a newline, whereAMOUNThas exactly two decimals andNcounts the calls: 1 on the first call, 2 on the second, and so on, no matter which receipt is printed. Keep the counter in astaticlocal variable inside the function; do not add a member to the class. The hidden driver reads a count, then that many customer lines each followed by an amount line, prints every receipt once and then prints the FIRST receipt again. Write toosand return it. For the input2,Mina,42.5,Omar,7the driver prints the output shown in Expected Output. Do NOT write a main function.
Expected Output:
Receipt 1 for Mina: 42.50 Receipt 2 for Omar: 7.00 Receipt 3 for Mina: 42.50
= newline. The output ends with a newline — 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.