fork download
  1. // Nathan Dominguez CSC5 Chapter 5, P. 294, #4
  2. //
  3.  
  4. /*******************************************************************************
  5.  *
  6.  * Compute Calories Burned
  7.  * _____________________________________________________________________________
  8.  * This program will calculate and display the amount of calories burned while
  9.  * running on a certain treadmill after 10, 15, 20, 25, and 30 minutes. While
  10.  * running on this particular treadmill a person will burn 3.9
  11.  * calories per minute.
  12.  *______________________________________________________________________________
  13.  * INPUT
  14.  *
  15.  * OUTPUT
  16.  * minutes : amount of time that has passed on the treadmill
  17.  * (10, 15, 20, 25, 30)
  18.  * calories : amount burned after being on the treadmill
  19.  * Formula
  20.  * caloriesBurned = time * caloriesPerMinute
  21.  ******************************************************************************/
  22. #include <iostream>
  23. #include <iomanip>
  24. using namespace std;
  25.  
  26. int main()
  27. {
  28.  
  29. // Declare Variables
  30. float caloriesBurned; //output - how many calories burned after each time interval
  31. float caloriesPerMinute = 3.9; // burn 3.9 caloriesperminute on treadmill
  32. int t; // t stand for time
  33. //Calculate Results
  34. //
  35. for (t = 10; t <= 30; t+=5)
  36. {
  37. caloriesBurned = i * caloriesPerMinute;
  38.  
  39. // Output the Results
  40. cout << "In " << t << " minutes you burned " << caloriesBurned << " calories." << endl;
  41.  
  42. }
  43. }
  44.  
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
In 10 minutes you burned 39 calories.
In 15 minutes you burned 58.5 calories.
In 20 minutes you burned 78 calories.
In 25 minutes you burned 97.5 calories.
In 30 minutes you burned 117 calories.