Skip to content

Instantly share code, notes, and snippets.

@helospark
Created October 15, 2020 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helospark/e86d50eae33418b1d198c4ed5b77e560 to your computer and use it in GitHub Desktop.
Save helospark/e86d50eae33418b1d198c4ed5b77e560 to your computer and use it in GitHub Desktop.
package com.helospark.bike;
/**
* Calculates the amount of calories & body fat burned from generated electric power in my exercise bike generator.
* @author helospark
*/
public class ExerciseBikeWhToKcal {
static final int wh = 95;
public static void main(String[] args) {
final double muscleEfficiency = 0.2;
final double generatorEfficiency = 0.8;
final double kcalToWh = 1.163;
final double kcalPerKgOfFat = 7700;
double caloriesBurned = wh * (1.0 / kcalToWh) * (1.0 / muscleEfficiency) * (1.0 / generatorEfficiency);
double fatBurned = caloriesBurned / kcalPerKgOfFat;
System.out.printf("%.1f kcal\n", caloriesBurned);
System.out.printf("%.3f kg of fat burned\n", fatBurned);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment