// Torrez, Elaine CS1A Chapter 5 P. 294, #4
/******************************************************************************************
*
* Calories Burned on Treadmill
*
* --------------------------------------------------------------------------------
* This program calculates and displays the number of calories burned after a set
* number of minutes on a treadmill. The treadmill burns 3.9 calories per minute.
* The program uses a loop to display the calories burned after 10, 15, 20, 25,
* and 30 minutes.
* --------------------------------------------------------------------------------
*
* INPUT
* minutes : Number of minutes (loop variable, 10 to 30 in steps of 5)
* caloriesPerMinute : Constant rate of calories burned (3.9 calories per minute)
*
* OUTPUT
* caloriesBurned : Calories burned at each time interval
*
*******************************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
const double caloriesPerMinute = 3.9; // Calories burned per minute
double caloriesBurned; // OUTPUT - Total calories burned
int minutes; // Loop variable
cout << "Minutes\tCalories Burned" << endl;
cout << "-------------------------" << endl;
// Loop to calculate calories burned at each interval
for (minutes = 10; minutes <= 30; minutes += 5)
{
caloriesBurned = minutes * caloriesPerMinute;
cout << setw(4) << minutes << "\t\t" << fixed << setprecision(1)
<< caloriesBurned << endl;
}
return 0;
}