Write a C++ program that reads string expressions from an input file \"prefix.tx
ID: 3825317 • Letter: W
Question
Write a C++ program that reads string expressions from an input file "prefix.txt" containing prefix expressions (one expression per input line). For each prefix expression read from the input file, the program should: (1) convert the expression to a fully parenthesized infix expression and (2) find the value of the expression. Use a stack to solve the problem. Assume the expressions contain only integer numbers and the *,/, +, - operators. Generate the results in an output file "results.txt" in the form of a table with 3 columns as shown in the example below. Example of an input file "prefix.txt": The obtained results.txt" output file for the above example of input file:Explanation / Answer
#include #include #include #include typedef std::deque tokens_t; void pre_to_in( tokens_t* eq ) { if ( !eq->empty() ) { const std::string token = eq->front(); eq->pop_front(); if ( ( token == "+" ) || ( token == "-" ) || ( token == "/" ) || ( token == "*" ) ) { std::coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.