CJCoding With Joseph
15free / daySign inCreate account

Build a Book From a Pipe-Delimited Record

Complete the constructor Book(const string& record). The record always has the shape ISBN|TITLE|COPIES|PRICE, but any token may carry extra spaces around it: 9781 | The Hobbit |3| 12.5 must produce isbn 9781, title The Hobbit (inner spaces kept), 3 copies and price 12.5. Use find to locate the three bars, substr to cut each token out, the provided trim helper to strip the spaces, then stoi for the two whole numbers and stod for the price.

The getters are already written. The hidden driver reads one record per line, builds a Book from each and prints the isbn, the title in square brackets, the copies and the price with two decimals, separated by single spaces.

Do NOT write a main function.

Expected Output:

9781 [The Hobbit] 3 12.50
42 [Dune] 10 8.00

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

Hints4 available
Topics:
Classes
📥 Auto-Input:
9781 | The Hobbit |3| 12.5\n 42|Dune| 10 |8\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.