fork download
  1. //Nicolas Ruano CS1A Ch. 5 Pp.294 #4
  2. /******************************************************************************
  3.  * THE NUMBER OF CALORIES
  4.  *
  5.  * We calculate how many calories burned after a person runs down to a
  6.  * particular treadmill and how minute minuts does it take to burn.
  7. *******************************************************************************
  8.  * INPUT
  9.  * the number of calories burned up to 3.9 cal. per minute. We will be using a
  10.  * for loop to see what this can be.
  11.  *
  12.  * List out a display of how many minutes you have burnt calories
  13.  *
  14.  * OUTPUT
  15.  * Display the number of calories burnt, showing how many minutes you've
  16.  * exercised
  17. ******************************************************************************/
  18. #include <iostream>
  19. #include <iomanip>
  20. using namespace std;
  21.  
  22. int main() {
  23. const double CALORIES_PER_MINUTE = 3.9; //Constant rate
  24. double calories;
  25.  
  26. cout << "Minutes\tCalories Burned" << endl;
  27. cout << "------------------------" << endl;
  28.  
  29. // Loop through 10, 15, 20, 25, 30
  30. for (int minutes = 10; minutes <= 30; minutes += 5) {
  31. calories = minutes * CALORIES_PER_MINUTE;
  32. cout << setw(3) << minutes << "\t"
  33. << fixed << setprecision(1) << calories << endl;
  34. }
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
Minutes	Calories Burned
------------------------
 10	39.0
 15	58.5
 20	78.0
 25	97.5
 30	117.0