[Solved] SOLVED:Data Structures- a program that is a backend for a very simple calcular.

30 $

File Name: SOLVED:Data_Structures-_a_program_that_is_a_backend_for_a_very_simple_calcular..zip
File Size: 744.18 KB

SKU: [Solved] SOLVED:Data Structures- a program that is a backend for a very simple calcular. Category: Tag:

Or Upload Your Assignment Here:


In this project you will work on a program that is a backend for a very simple calcular. Your calculator takes as input simple mathematicalexpressions like23 – 2 * 54 – 9 * 11 + 155 * ( 21 – 17 )/ 3( ( 15 / ( 7 – ( 1 + 1 )))- ( 2 + ( 1 + 1 ))and determines their valueInput File Your program is given the name of the input text file on its command line (the first argument). The text file containsmathematical expressions (like the ones above). There is always only one expression per line. Each valid expression consists of tokensseparated by one or more spaces. A token is either a positive integer, an operator (+,-,*,/), or an open or a closed parenthesis. Theinput file may contain empty lines.If the filename is omitted from the command line, it is an error. The program should display an error message and terminate. The errormessage should indicate what went wrong (for example: ”Error: missing name of the input file”).If the filename is given but the file does not exist or cannot be opened for reading by the program, for any reason, it is an error. Theprogram should display an error message and terminate. The error message should indicate what went wrong (for example: ”Error: filecalculations.txt does not exist.”, but make sure to replace the name with the name of the file with which the program was called).Your program is NOT ALLOWED to hardcode the input filename in its own code. It is up to the user of the program to specify the nameof the input file. Your program should not modify the name of the user-specified file (do not append anything to the name).Your program may not read the input file more than once.Your program may not modify the input file.Your program is given the name of the output text file on its command line (the second argument). As your programevaluates each of the expressions in the input file, the results of computations should be printed to the output file. If a correspondingexpression in the input file is not valid or contain a blank line, your program should print INVALID instead of the result and continuewith the next expression. The results should be printed one per line.If the filename is omitted from the command line, it is an error. The program should display an error message and terminate. The errormessage should indicate what went wrong (for example: ”Error: missing name of the output file”).If the filename is given but the file with a provided name cannot be created for any reason, it is an error. The program should display anerror message and terminate. The error message should indicate what went wrong (for example: ”Error: file results.txt could notbe created.”, but make sure to replace the name with the name of the file with which the program was called).If the file with a given filename already exists, the program should overwrite it. If the file with a given filename does not exist, yourprogram should create it.

Your program must contain multiple classes (in multiple files) and must be developed in an object oriented way. You will need to developthe following classes:• Calculator – the class that provides the main() method. This class is responsible for all input and output operations (theinput file should be read by this class, and the class should write the results to the output file).• ExpressionTools – the class that provides the methods for infix to postfix conversion and for postfix evaluation. This classprovides only tools (like the Math class, so you should never need to create an instance of this class and all of its methods shouldbe static).• MyStack – the class that provides a reference based implementation of the interface provided below (you will not get any creditfor this class if it is implemented using arrays or if it uses the Stack implementation from Java API).• PostFixException – the class that represent the exception that should be thrown when errors in the expression occur.The program should read each of the expressions from the input file, convert it to the postfix expression, evaluate the postfix expressionand print the result to the output file .

MyStack classBoth of the above algorithms need to use a stack. You should implement your own reference based stack that follows the followinginformal interface:Stack() Creates an empty Stack.boolean empty() Tests if this stack is empty.E peek() Looks at the object at the top of this stack without removing it from the stack.E pop() Removes the object at the top of this stack and returns that object as the value of this function.E push(E item) Pushes an item onto the top of this stack.int search(Object o) Returns the 1-based position where an object is on this stack.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] SOLVED:Data Structures- a program that is a backend for a very simple calcular.
30 $