fork download
  1. // Drew Duffey CSC5 Chapter 5, P.294, #4
  2. //
  3. /*******************************************************************************
  4.  *
  5.  * CALCULATE CALORIES
  6.  * _____________________________________________________________________________
  7.  * This program will calculate the amount of calories burned in certain time
  8.  * intervals.
  9.  * _____________________________________________________________________________
  10.  * INPUT
  11.  * Although this program does not have any user input, we have some given input
  12.  * from the book, that being the time intervals and calories per minute burned
  13.  *
  14.  * OUTPUT
  15.  * Calories Burned : The number of calories burned at the current time interval
  16.  *
  17. *******************************************************************************/
  18. #include <iostream>
  19. #include <iomanip>
  20. using namespace std;
  21. int main ()
  22. {
  23. float calsBurned;//OUTPUT - The number of calories burned at the current
  24. //time interval
  25. int mins;//CALC - minutes run on treadmill so far, used to calculate time
  26. //intervals
  27.  
  28. for (mins = 10; mins <= 30; mins += 5)
  29. {
  30. calsBurned = 3.9 * mins;
  31. cout << "At " << mins << " minutes, you have burned " << calsBurned <<
  32. " calories.\n";
  33. }
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
At 10 minutes, you have burned 39 calories.
At 15 minutes, you have burned 58.5 calories.
At 20 minutes, you have burned 78 calories.
At 25 minutes, you have burned 97.5 calories.
At 30 minutes, you have burned 117 calories.