Skip to content

Instantly share code, notes, and snippets.

@helospark
Created October 15, 2020 17:11
Show Gist options
  • Save helospark/6b0e92d01b92b4fae28365e83c3a8eeb to your computer and use it in GitHub Desktop.
Save helospark/6b0e92d01b92b4fae28365e83c3a8eeb to your computer and use it in GitHub Desktop.
package com.helospark.bike;
/**
* Calculates how many watts I have to generate to burn the amount of calories on my exercise bike generator.
* @author helospark
*/
public class ExerciseBikeKcalToWh {
static final int kcalEaten = 640;
public static void main(String[] args) {
final double muscleEfficiency = 0.2;
final double generatorEfficiency = 0.8;
final double kcalToWh = 1.163;
final double avgWatts = 100.0;
double whGenerated = kcalEaten * (kcalToWh * muscleEfficiency * generatorEfficiency);
double timeToGenerate = whGenerated / avgWatts;
System.out.printf("%.2f Wh\n", whGenerated);
System.out.printf("%d min\n", (int) (timeToGenerate * 60));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment