Simple Java math operations
Posted
by
user1730056
on Stack Overflow
See other posts from Stack Overflow
or by user1730056
Published on 2012-11-25T11:01:33Z
Indexed on
2012/11/25
11:03 UTC
Read the original article
Hit count: 156
java
I'm making a BMI calculator that doesn't seem to be working.
The math operations work if i just do something like w/h, but once i had the brackets, it returns an error.
If i change the variables w and h and use a constant number, the operation works.
Another problem is that although i'm making result
a double, it seems to be rounding to the nearest int.
Could someone tell me what I'm doing wrong here?
public class ass10 {
public static void main(String[] args) {
bmi(223,100);
}
public static bmi(int w, int h){
double result;
result = (w/(h*h))*703
System.out.println(result)
}
}
© Stack Overflow or respective owner