Question: Program must be written in C++: Write a program that creates a vector of strings called V. Vector V grows and shrinks as the user
Program must be written in C++: Write a program that creates a vector of strings called V. Vector V grows and shrinks as the user processes the transactions from a data file called data.txt. The transaction file can only include three commands: Insert, Delete and Print. With Insert command, you get two more information, the information you need to insert and the position it should be inserted. With Delete, you get one more information that indicates which element (index) should be deleted. Print command means the content of the vector should be printed on the screen. For example, you may have the following information in your file: Insert Hello 4 Delete 5 Print The first line indicates that The word Hello should be inserted in V[4]. Of course you should check if this insert is possible. This insert is possible if the position you are attempting to insert the element is not beyond the size of the vector. The second line means V[5] should be removed. Again this operation should only be allowed if the index is not beyond the current size of the vector. Test your program with the following transaction file: Insert Total 0 Insert Normal 0 Insert Perfect 1 Insert Program 1 Insert Book 2 Print Insert Perfect 5 Delete 1 Delete 7 Insert Money 2 Delete 3 Print Note: Each command must be implemented in a separate function.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
