Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language is c++. please use comments. You need to create a C+ program to manage a list of books. Each book will have attributes: e

image text in transcribedimage text in transcribed

Language is c++. please use comments.

You need to create a C+ program to manage a list of books. Each book will have attributes: e book id . book_name author name You may need to add or remove books from the ist. You may also need to sort the list of books. 2. Program and Input Specification You will have an input file containing a list of books. Each line will be treated as a single book's information. Each book's information format will be e book_id:book id, book nane:book name, book outhor.author name In command.txt file, you will get corresponding command that you need to execute. You may get add, remove, or sort command. Command formats are, . add pos:insert position, book_id: boak id, book_name: book name, book outhor: author name remove keyword:value keyword is one of: pas, book id, book name, or book author o e sort keyword o keyword is one of: book id, book nome, ar boak author Your command file may contain multiple commands. Each line will have a single command. You will execute all commands sequentially one by one. The input file is a small plain text file; no need to handle binary files. .Each line will be terminated with a new line, n', character * Before executing any command, all records will be sequentially added fromm e If you get same book name or author name, but not same book id, then you e If you get an 'add' command, then you will add the book in the list at the the input file. need to add the book. provided position. o 0 is the starting index o If you get index number that daes not exist in the list, then you will add the record at the end of the list If you get existing book id, le., the book id is the same as an existing book id, you will not add the book o e If you get a delete' command with book_name, or book author keywords, then you will delete all records that matches with the book name or author name e If you get 'delete command with pos keyword, then you will delete that position record. o Index starts from O o If you get invalid position, one that does not exist, then you do not need to delete any record * You may need to handle a maximum 1000 records. . You may get a maximum 100 commands in a single command file. . Book ID will be always five-digit number If you get an empty line, then you will ignore it. . Sorting will be always in ascending order. You need to sort the list based on the provided keyword. e All records are case sensitive The main C++ program will become the executable to be tested by the TAs. The Result file should be written to another text file (output file), provided with the Command line. Notice the input and output files are specified in the command line, not inside the C++ code. Notice also the quotes in the program call, to avoid Unix/Windows getting confused. See part 4 3. Output Specification The output file will contain the list of records after executing all commands. All records should be processed sequentially from beginning to end. Please, see 3. Output Specification The output file will contain the list of records after executing all commands. All records should be processed sequentially from beginning to end. Please, see examples for clarification about the format. 4. Program Execution: The general call to the executable is as follows: You can call the executable with another command line type 5. Examples Example 1 of input and output, Input21.txt book id:32452, book_name:Data Structures Using C++, book author:D. S. Malik book id:12452, book name:Computer Networks, book author:Peterson Davie book_id:32432, book_name:Introduction to Algorithms, book author:Thomas H. Cormen book_id:32423, book name:Algorithms in C++, book author:Robert Sedgewick Command21.txt sort book id add pos:2 book_id:12456, book_ name:Programming and Data Structures, book author:xxx Command line: output21txt book_id:12452, book_name:Computer Networks, book author Peterson Davie book id:32423, book_name:Algorithms in C++, book author:Robert Sedgewick book_id:12456, book_name:Programming and Data Structures, book author:xx book id:32432, book name:Introduction to Algorithms, book author:Thomas H. Cormen book_id:32452, book_name:Data Structures Using C++, book author:D. S. Malik First your program will sort the book list, then it will add another book in the list at position 2, finally it will generate the output. Example 2 of input and output, Input 22.txt book_id:32452, book_name:Data Structures Using C++, book author:D. S. Malik book_id:12452, book_name:Computer Networks, book author:Peterson Davie add pos:2 book_id:12452, book_name:Introduction to Algorithms, book author:Thomas H. Cormen remove book author Peterson Davie Command line: 22.txt output-output22.txt output22.txt book_id:32452, book_name:Data Structures Using C++, book author:D. S. Malik Book id '12452' matches with existing record, thus the book will not be added. The program will generate output after removing the book by matching the author name Example 3 of input and output, You need to create a C+ program to manage a list of books. Each book will have attributes: e book id . book_name author name You may need to add or remove books from the ist. You may also need to sort the list of books. 2. Program and Input Specification You will have an input file containing a list of books. Each line will be treated as a single book's information. Each book's information format will be e book_id:book id, book nane:book name, book outhor.author name In command.txt file, you will get corresponding command that you need to execute. You may get add, remove, or sort command. Command formats are, . add pos:insert position, book_id: boak id, book_name: book name, book outhor: author name remove keyword:value keyword is one of: pas, book id, book name, or book author o e sort keyword o keyword is one of: book id, book nome, ar boak author Your command file may contain multiple commands. Each line will have a single command. You will execute all commands sequentially one by one. The input file is a small plain text file; no need to handle binary files. .Each line will be terminated with a new line, n', character * Before executing any command, all records will be sequentially added fromm e If you get same book name or author name, but not same book id, then you e If you get an 'add' command, then you will add the book in the list at the the input file. need to add the book. provided position. o 0 is the starting index o If you get index number that daes not exist in the list, then you will add the record at the end of the list If you get existing book id, le., the book id is the same as an existing book id, you will not add the book o e If you get a delete' command with book_name, or book author keywords, then you will delete all records that matches with the book name or author name e If you get 'delete command with pos keyword, then you will delete that position record. o Index starts from O o If you get invalid position, one that does not exist, then you do not need to delete any record * You may need to handle a maximum 1000 records. . You may get a maximum 100 commands in a single command file. . Book ID will be always five-digit number If you get an empty line, then you will ignore it. . Sorting will be always in ascending order. You need to sort the list based on the provided keyword. e All records are case sensitive The main C++ program will become the executable to be tested by the TAs. The Result file should be written to another text file (output file), provided with the Command line. Notice the input and output files are specified in the command line, not inside the C++ code. Notice also the quotes in the program call, to avoid Unix/Windows getting confused. See part 4 3. Output Specification The output file will contain the list of records after executing all commands. All records should be processed sequentially from beginning to end. Please, see 3. Output Specification The output file will contain the list of records after executing all commands. All records should be processed sequentially from beginning to end. Please, see examples for clarification about the format. 4. Program Execution: The general call to the executable is as follows: You can call the executable with another command line type 5. Examples Example 1 of input and output, Input21.txt book id:32452, book_name:Data Structures Using C++, book author:D. S. Malik book id:12452, book name:Computer Networks, book author:Peterson Davie book_id:32432, book_name:Introduction to Algorithms, book author:Thomas H. Cormen book_id:32423, book name:Algorithms in C++, book author:Robert Sedgewick Command21.txt sort book id add pos:2 book_id:12456, book_ name:Programming and Data Structures, book author:xxx Command line: output21txt book_id:12452, book_name:Computer Networks, book author Peterson Davie book id:32423, book_name:Algorithms in C++, book author:Robert Sedgewick book_id:12456, book_name:Programming and Data Structures, book author:xx book id:32432, book name:Introduction to Algorithms, book author:Thomas H. Cormen book_id:32452, book_name:Data Structures Using C++, book author:D. S. Malik First your program will sort the book list, then it will add another book in the list at position 2, finally it will generate the output. Example 2 of input and output, Input 22.txt book_id:32452, book_name:Data Structures Using C++, book author:D. S. Malik book_id:12452, book_name:Computer Networks, book author:Peterson Davie add pos:2 book_id:12452, book_name:Introduction to Algorithms, book author:Thomas H. Cormen remove book author Peterson Davie Command line: 22.txt output-output22.txt output22.txt book_id:32452, book_name:Data Structures Using C++, book author:D. S. Malik Book id '12452' matches with existing record, thus the book will not be added. The program will generate output after removing the book by matching the author name Example 3 of input and output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions

Question

,3.6.2. Find the variance of Y if 3 fY0') = 1 O, elsewhere

Answered: 1 week ago

Question

=+will appear. Make sure it's portable. Ask yourself:

Answered: 1 week ago