You need to create a C++ program that can evaluate a list of arithmetic expressions whether they are valid. You also need to compare them if they are similar. You will get a list of expressions in an input file. Each line will be considered as a single expression. You need to check whether the expression is valid or not. An expression will be invalid if opening and ending parenthesis don't match. If you don't get any invalid expression, then you need to check the similarity among all expressions. Expressions will be similar, if we place values to the variables then all expressions will generate the same result. Assumptions: The input file is a small plain text file; no need to handle binary files. Each input file may contain maximum 1000 expressions. In an expression, only unit digits (0-9) will be used. Variables can be only (a-z, and A-Z), and it is always a single character. There will be no space in an expression. An input file may contain empty lines between expressions, then you will ignore it. • Operators: + -. Parentheses: (, ), { }, [, ]- The output should be exactly matched with the format. The input file is a regular text file, where each line is terminated with a '\n' character. Each line will contain an arithmetic expression. 1. Expressions consist of numbers (0-9), lowercase alphabets (a-z), uppercase alphabets (A-Z), t', '-', '(', )', {, Y, T, and J'. An operand (numbers, and alphabets) will not appear the second time in a single expression. 2. If an expression is not valid, the output will be "Error at: "+expression number. Note, in "Error at: ", there is a space after the colon(:). 3. If Expressions are similar, then the output will be "Yes", otherwise "No". All records should be processed sequentially from beginning to end. Note that, input and output, all are case sensitive. Please, see examples to be clarified about the format and expression number. Examples Example 1 of input and output, Input1.txt a+b-A-1+3+B a+b-1+3+B-A +(a+b-A-1+3+B) a+b-(A+1)+3+B a+b-(A+1)-(-3-B) a+(b-(A+1)+3+B) a+{(b-[A+1])+3+B} a+b-A+2+B Command line: evalexpr input=input1.txt output=output1.txt Output1.txt Yes Example 2 of input and output, Input2.txt A+B+5+6+a A-B+5+6+a Command line: evalexpr input=input2.txt output=output2.txt Output2.txt No Example 3 of input and output, Input3.txt // valid expression // valid expression // valid expression a+b+c+d+e a-b-c-d-e a-(b-c-d)-e a-{(b-c-d)-e // Error // Empty line will not be counted // Error a-{(b-c-d))-e // Empty line will not be counted // valid expression // Error // Error {a-[(b-c-d)]-e} a-[{(b-c-d})]-e a-{(b-[c-d)}-e] Command line: evalexpr input=input3.txt output=output3.txt Output3.txt Error at: 4 Error at: 5 Error at: 7 Error at: 8 The general call to the executable is as follows: evalexpr input=input1.txt output=output1.txt
You need to create a C++ program that can evaluate a list of arithmetic expressions whether they are valid. You also need to compare them if they are similar. You will get a list of expressions in an input file. Each line will be considered as a single expression. You need to check whether the expression is valid or not. An expression will be invalid if opening and ending parenthesis don't match. If you don't get any invalid expression, then you need to check the similarity among all expressions. Expressions will be similar, if we place values to the variables then all expressions will generate the same result. Assumptions: The input file is a small plain text file; no need to handle binary files. Each input file may contain maximum 1000 expressions. In an expression, only unit digits (0-9) will be used. Variables can be only (a-z, and A-Z), and it is always a single character. There will be no space in an expression. An input file may contain empty lines between expressions, then you will ignore it. • Operators: + -. Parentheses: (, ), { }, [, ]- The output should be exactly matched with the format. The input file is a regular text file, where each line is terminated with a '\n' character. Each line will contain an arithmetic expression. 1. Expressions consist of numbers (0-9), lowercase alphabets (a-z), uppercase alphabets (A-Z), t', '-', '(', )', {, Y, T, and J'. An operand (numbers, and alphabets) will not appear the second time in a single expression. 2. If an expression is not valid, the output will be "Error at: "+expression number. Note, in "Error at: ", there is a space after the colon(:). 3. If Expressions are similar, then the output will be "Yes", otherwise "No". All records should be processed sequentially from beginning to end. Note that, input and output, all are case sensitive. Please, see examples to be clarified about the format and expression number. Examples Example 1 of input and output, Input1.txt a+b-A-1+3+B a+b-1+3+B-A +(a+b-A-1+3+B) a+b-(A+1)+3+B a+b-(A+1)-(-3-B) a+(b-(A+1)+3+B) a+{(b-[A+1])+3+B} a+b-A+2+B Command line: evalexpr input=input1.txt output=output1.txt Output1.txt Yes Example 2 of input and output, Input2.txt A+B+5+6+a A-B+5+6+a Command line: evalexpr input=input2.txt output=output2.txt Output2.txt No Example 3 of input and output, Input3.txt // valid expression // valid expression // valid expression a+b+c+d+e a-b-c-d-e a-(b-c-d)-e a-{(b-c-d)-e // Error // Empty line will not be counted // Error a-{(b-c-d))-e // Empty line will not be counted // valid expression // Error // Error {a-[(b-c-d)]-e} a-[{(b-c-d})]-e a-{(b-[c-d)}-e] Command line: evalexpr input=input3.txt output=output3.txt Output3.txt Error at: 4 Error at: 5 Error at: 7 Error at: 8 The general call to the executable is as follows: evalexpr input=input1.txt output=output1.txt
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
c++. output
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 5 steps with 5 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education