Netbeans Calculator - Problems with Decimal Operations

Asked

Viewed 132 times

3

Hey, good night, man. I’m having to do a calculator job, and my code performed operations like 8+9, 1+7 normally, but it wasn’t 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. inteiro *=10; inteiro += 8; But why put "10" and an asterisk in front of the same? And a "+" in front of the equal in the bottom? And one more thing, now it is not performing decimal operations. The comma even appears on the screen, but when executing the operation, it understands that the number is integer. Type 1,1+1 and he gives me the result as 12. Very grateful, from now on.

1 answer

2


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

inteiro *= 10;

Is the same as:

inteiro = inteiro * 10;

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.