(* treadmill.pas - Determine how many calories are burned on the treadmill. * We need the following numbers from the user: * Speed, incline, time, weight * Formula comes from * https://www.livestrong.com/article/34973-calculate-treadmill-calories *) program treadmill; var pounds, kg, mph, mpm, incline, minutes, oxygen, cpm, calories: real; begin (* Input *) write('Enter your weight in pounds: '); readln(pounds); write('How fast did you go (mph)? '); readln(mph); write('What was the % incline? '); readln(incline); write('How many minutes did you walk/run? '); readln(minutes); (* Calculations: * Let's begin with the necessary unit conversions. * Convert speed to meters per minute, percent grade to a decimal, * and weight to kilos. *) mpm := 26.8 * mph; incline := incline / 100.0; kg := pounds / 2.2; (* Now we are ready for the oxygen formula: ml per kg per minute. * It assumes 3.7 mph represents walking and uses a different for running. *) if mph <= 3.7 then oxygen := 0.1 * mpm + 1.8 * mpm * incline + 3.5 else oxygen := 0.2 * mpm + 0.9 * mpm * incline + 3.5; (* Now calculate calories per minute, and the total calories. *) cpm := oxygen * kg / 200.0; calories := cpm * minutes; (* Output. Precede the output with an empty writeln to visually * separate the input from output. *) writeln(); writeln('Your speed was ', mpm, ' meters per minute.'); writeln('You consumed ', oxygen, ' ml of oxygen per kg per minute.'); writeln('You burned ', cpm, ' calories per minute.'); writeln('Finally, you burned ', calories, ' calories.'); end.