NetBeans Calculator - Problems with decimal operations

3

Hello, good evening. I'm having to do a calculator job, and my code performed operations like 8 + 9, 1 + 7 normally, but I was not doing 10 + 20 = 3, 50 + 7 = 12; the result was always the sum of the first numbers. The detail of putting the integer = 10; and integer + = 8; as in the photo helped a lot. Butwhyput" 10 " and an asterisk in front of equals? And a " + " in front of the equal on the bottom? And one more thing, now she is not performing decimal operations. The comma even appears on the screen, but at the time of executing the operation, it understands that the number is integer. I type 1.1 + 1 and it gives me the result as 12 . Very grateful, right away.

    
asked by anonymous 04.05.2015 / 02:58

1 answer

2

*= means that you are doing a multiplication operation and assigning the result to the variable that precedes the operator. This way:

inteiro *= 10;

Is the same as:

inteiro = inteiro * 10;

As to why your calculator's operations do not work as they should, I suggest that you review your algorithm before continuing to encode.

    
04.05.2015 / 03:29