Im new to java and im trying to do a very simple Bmi calculator, it goes like this:
public static void main(String[] args) {
int weight = 90;
int height = 185;
int result = ( weight / ( height * height));
System.out.println(result);
I don“t fucking understand why when I run it I get a result of 0. Same thing if I put the numbers in a calculator also get a zero. Wtf is wrong?
try using double instead of int
>>113940
Integers don't work for decimals.
It worked! thanks Anon!
>>113950
;)
You should look up what "int" and "double" actually mean. This isn't all as simple as "int is for integers, double is for fractions".
or you can also use float, which would be even better.
int is for integers, float is for small fractions (7digits) and double has the double of capacity (15 digits)