[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Java Bmi Formula
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /wsr/ - Worksafe Requests

Thread replies: 7
Thread images: 1
File: java.jpg (7 KB, 225x225) Image search: [Google]
java.jpg
7 KB, 225x225
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)
Thread replies: 7
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.