Question #47847

Running on a particular treadmill you burn 3.9 calories per minute. Write a program that uses a
loop to display the number of calories burned after 10, 15, 20, 25, and 30 minutes.
1

Expert's answer

2014-10-14T10:10:45-0400

Answer on Question #47847, Engineering, Other

Question:

Running on a particular treadmill you burn 3.9 calories per minute. Write a program that uses a loop to display the number of calories burned after 10, 15, 20, 25, and 30 minutes.

Answer:

Tested on MS Visual Studio C++

#include <iostream>

#include <cstdlib>

void main (void) {

float n_calories = 0.0;

for (int minute=1; minute<=30; minute++) {

n_calories += 3.9;

if (minute%5 == 0 && minute > 5)

std::cout << "Number of calories burned after" << minute << "minutes - " << n_calories << std::endl;

}

system ("pause");

} Output:

Number of calories burned after 10 minutes - 39

Number of calories burned after 15 minutes - 58.5

Number of calories burned after 20 minutes - 78

Number of calories burned after 25 minutes - 97.5

Number of calories burned after 30 minutes - 117

https://www.AssignmentExpert.com</cstdlib></iostream>


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS