← Back to Classes
Question 722
Build a Book From a Pipe-Delimited Record
Build a Book From a Pipe-Delimited Record
Complete the constructorBook(const string& record). The record always has the shapeISBN|TITLE|COPIES|PRICE, but any token may carry extra spaces around it:9781 | The Hobbit |3| 12.5must produce isbn 9781, titleThe Hobbit(inner spaces kept), 3 copies and price 12.5. Usefindto locate the three bars,substrto cut each token out, the providedtrimhelper to strip the spaces, thenstoifor the two whole numbers andstodfor 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
Sign in to use hintsTopics:
Classes
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.