Question: Instructions: Using Microsoft Visual Studio 2017 C++, Suppose an expression is represented in a string (i.e., 35 * 4 + 5 / (4 + 5)).
Instructions: Using Microsoft Visual Studio 2017 C++, Suppose an expression is represented in a string (i.e., 35 * 4 + 5 / (4 + 5)). Write a function that splits the expression into numbers, operators, and parentheses. The function takes an expression as the argument and returns a vector of strings. Each string represents a number, an operand, or a parenthesis. The header of the function is given as follows: Vector split (const string &expression) For example, split(35 * 4 + 5 / (4 + 5)) returns a vector that contains the strings 35, *, 4, +, 5, /, (, 4, +, 5, ). Write a test program that prompts the user to enter an expression and displays the split items in reverse order. Program Hints: 1. Use the vector class from the standard template library. 2. Declare a string variable to store the expression input by the user 3. Write function split of type vector that is passed your expression a. Your function will need a local string variable to build your number string b. Loop through each character in expression. i. If the character is a digit, append it to your number string ii. If the character is not a digit and you have a number string with size > 0 store the number string in the vector, and erase the number string iii. If the character is a space, add the next character (an operator) to the vector c. After the loop, if the size of the number string is > 0, add it to the vector
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
