Ticket Line That Leaves the Stream Untouched
mediumQuestion 724Ticket 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, so print one after the last line.
Your output
Run your code to see the output here...