fork download
  1. //Andres Guzman CSC5 Chapter 5, P. 294, #4
  2. //
  3. /*******************************************************************************
  4. *
  5. * CALCULATE CALORIES BURNED
  6. * ______________________________________________________________________________
  7. * This program will calculate the total calories burned within the specified times.
  8. *
  9. * Computation is based on the formula:
  10. *
  11. * burn = min * cpm.
  12. * ______________________________________________________________________________
  13. * INPUT
  14. *
  15. * cpm = calories per minute
  16. *
  17. * OUTPUT
  18. *
  19. * burn = total calories burned by the specified time
  20. *
  21. *******************************************************************************/
  22. #include <iostream>
  23. using namespace std;
  24. int main ()
  25. {
  26. float cpm = 3.9; //The calories burnt per minute
  27. int min = 5; //Counter beginning at 5
  28. //
  29. //Initlalizing While Loop & output results
  30. while (min < 30) //Limits the loops to only while minute is less than 30
  31. {
  32. min += 5; //adds 5 to min after each loop
  33. float burn = min * cpm; //calculates calories burned
  34. cout << "calories burned after " << min << " minutes: " << burn << endl;
  35. }
  36. return 0;
  37. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
calories burned after 10 minutes: 39
calories burned after 15 minutes: 58.5
calories burned after 20 minutes: 78
calories burned after 25 minutes: 97.5
calories burned after 30 minutes: 117