CJCoding With Joseph
15free / daySign inCreate account

Receipts Numbered by a Static Counter

Receipt is written for you with a friend declaration. Define ostream& operator<<(ostream& os, const Receipt& r) below the class so each call prints one line: Receipt N for CUSTOMER: AMOUNT followed by a newline, where AMOUNT has exactly two decimals and N counts the calls: 1 on the first call, 2 on the second, and so on, no matter which receipt is printed. Keep the counter in a static local 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 to os and return it.

For the input 2, Mina, 42.5, Omar, 7 the 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
Topics:
Streamsostream
📥 Auto-Input:
2\nMina\n42.5\nOmar\n7\n
This input is automatically fed to your program's stdin
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.