-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCalories.java
More file actions
65 lines (59 loc) · 1.84 KB
/
Calories.java
File metadata and controls
65 lines (59 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package conversion;
/**
* Estimates calories spent per step, based on biometric data
*
* @author Sunshine Regiment
*
*/
public final class Calories {
//base conversion factor
private final static double steps_conv = 0.0000004f;
/**
* Calculates various calories-related values for a given biometric profile
* @param profile Data about the person whose BMR we're calculating
* @return BMR
*/
public static double BaseMetabolicRate(BiometricProfile profile){
//calculates Base Metabolic Rate, this is needed to calculate calories per step, and see how active the person is
//gender: men = false, women = true
//weight in kg
//age in years
//height in m
double height = profile.getHeight();
double weight = profile.getWeight();
int age = profile.getAge();
boolean gender = profile.getGender();
double BMR;
if (gender){
//for women
BMR = 447.593 + (9.247 * weight) + (3.098 * height) - (4.330 * age);
}
else {
//for men
BMR = 88.362 + (13.397 * weight) + (4.799 * height) - (5.677 * age);
}
return BMR;
}
/**
* Calculates Recommended Daily Allowance of calories, based on personal data
* @param profile Data about the user that is used to make estimates
* @return RDA
*/
public static double dailyCalAllowed(BiometricProfile profile){
//Sex men = true, women = false
//weight in kg
//age in years
//height in metres
//RDA estimate in kcals
return 1.375 * BaseMetabolicRate(profile);
}
/**
* Calculates the approx. calories used per step taken by the user
* @param profile Personal data of the user
* @param steps_per_km Step length data
* @return Calroies per step taken
*/
public static double calsPerStep(BiometricProfile profile, double steps_per_km){
return profile.getWeight() * steps_per_km * steps_conv;
}
}