Android examples for java.lang:Math
calculate BMR for your body
/*/*from w ww. j a v a 2 s . com*/ * Copyright (C) 2015, Jhuster, All Rights Reserved * Author: Jhuster(lujun.hust@gmail.com) * * https://github.com/Jhuster/EWeightScale * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. */ //package com.java2s; import java.text.DecimalFormat; public class Main { public static final int UserSexMale = 0; public static double calculateBMR(int sex, double weight, double height, int age) { double result = 0.0; DecimalFormat format = new DecimalFormat("0.00"); if (sex == UserSexMale) { result = 655 + (9.6 * weight) + (1.8 * height) - (4.7 * age); } else { result = 66 + (13.8 * weight) + (5.0 * height) - (6.8 * age); } return Double.valueOf(format.format(result).toString()); } }