CJCoding With Joseph
15free / daySign inCreate account

Ticket Line That Leaves the Stream Untouched

Ticket is written for you, with a friend declaration for operator<<. Define the free function ostream& operator<<(ostream& os, const Ticket& t) below the class so that one ticket prints as a single line:

- Ticket  then the id right-aligned in 6 columns padded with 0
- :  then the event name right-aligned in 16 columns padded with .
- a space, the seat count right-aligned in 2 columns padded with spaces, then  seats @ 
- the price per seat with two decimals in 6 columns,  = , then the subtotal (seats times price) with two decimals in 7 columns
-  fee:  then 5% of the subtotal (FEE_RATE) with two decimals in 6 columns,  due:  then subtotal plus fee with two decimals in 7 columns, and a newline

After your function returns, os must have exactly the fill character, flags and precision it had before the call: the driver prints a width-6 integer and the plain double 3.14159 through the same stream afterwards. Write to os, never to cout, and return os.

For the input 17, Jazz Night, 3 45 the driver prints the output shown in Expected Output.

Do NOT write a main function.

Expected Output:

Ticket 000017: ......Jazz Night  3 seats @  45.00 =  135.00 fee:   6.75 due:  141.75
    42|3.14159

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Streamsostream
📥 Auto-Input:
17\nJazz Night\n3 45\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.