variable-calculator in java

Cancelado Postado há 6 anos Pago na entrega
Cancelado Pago na entrega

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

1e2

2 * ( 3 + 1 )

1.2 + 4.3

3 ** 5

5 / 3

Output:

5.00000

100.00000

8.00000

5.50000

ERROR

1.66667

Java Programming

ID do Projeto: #16012394

Sobre o projeto

10 propostas Projeto remoto Ativo em há 6 anos

10 freelancers estão ofertando em média ₹1365 nesse trabalho

Shankarone

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

₹1300 INR em 1 dia
(23 Comentários)
4.6
BeshoyMousaKhair

. Relevant Skills and Experience . Proposed Milestones ₹1500 INR - .

₹1500 INR em 1 dia
(29 Comentários)
4.2
amoldevadhe3

Hello, We have good experience of PHP,HTML,CSS, Ajax,JavaScript,Mysql, Website Design,Bootstrap, etc. Kindly give us an opportunity to work for you at our best. Thank you !! Relevant Skills and Experience Java, Progra Mais

₹1300 INR em 1 dia
(10 Comentários)
3.2
AmerSOthman94

Kindly, be advised that I do the potential and the skills required to accomplish this task with clear and solid code. Relevant Skills and Experience Java Object-oriented programmming XML (eXtensible Markup Language) M Mais

₹1300 INR em 1 dia
(3 Comentários)
2.9
AMancer

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

₹1300 INR em 1 dia
(4 Comentários)
2.6