The goal is to create a simple calculator that reads the input in the "common" notation (the infix notation).
The input is read from the standard input. The results are printed out to the standard output. The calculator allows for summing, subtracting, multiplying, and dividing. Priority of the operators is as usual and can be modified by the parentheses.
The numbers correspond to the Double type. The numbers can be written in any format that is acceptable by the [url removed, login to view]() method. The numbers can be negative (i.e., the unary minus can be used, too; the parseDouble() method can also read the unary minus). Also, take care about a number format with an exponent, the exponent written with a sign, etc.
In addition to numbers, the calculator allows for using variables. Variables are identified by a case-sensitive sequence of letters. A value is assigned to a variable by operator = (the equals sign). The value of a variable used for the first time in an expression is zero. Assigning a value to a variable is not an expression (i.e., it cannot be used in other expressions).
A value of a just-evaluated expression is always assigned to the special variable last, which can be used in the subsequent expression (in the first expression, the value of the last variable is zero). After assigning a value to a variable, the same value is also stored into last.
The expressions are separated by a new-line. Within a single line, numbers and operators are separated by an arbitrary number of white spaces (with the exception of the new-line). The result is printed out after the complete expression is read. If the given expression contains an error (an insufficient number of operands for an operator, insufficient operators for given operands, an unknown operator, a wrong number format, an invalid operation,...), the program prints out string ERROR. An empty line (or a line with white spaces only) is not considered as an error and it is ignored.
After printing out string ERROR, the last variable contains zero.
The results are printed out with the precision of 5 digits (i.e., 5 digits after the decimal point; the numbers can be printed out for example by the [url removed, login to view]("%.5f", number) method).
The program ends with the end of the input.
Ex: if Input:
3 + 2
2 * ( 3 + 1 )
1.2 + 4.3
3 ** 5
5 / 3
13 freelancer đang chào giá trung bình ₹1373 cho công việc này
I can complete this work in 6 hours time. Let me know if you'd like me to start working. Relevant Skills and Experience . Proposed Milestones ₹1300 INR - task completion
hello i'm a java developer , i read your description . please contact me soon over chat thank you. Relevant Skills and Experience JAVA Proposed Milestones ₹1300 INR - project milestone