In: Computer Science
Calories Burned
Running on a particular treadmill, you burn 4 calories per minute. Write a program that uses a loop to display the number of calories burned after 5, 10, 15, 20, 25, and 30 minutes.
Note the answer should be in assembly language using windows 32 and .586
#include <iostream>
#include <iomanip>
using namespace std;
// =============================================================
int main(){
cout<<"============================================\n";
cout<<"\t :: Information ::\n";
cout<<"This program is used to display the total\n";
cout<<"number of the burned calories after running\n";
cout<<"specific intervals from 5 to 30 minutes.\n";
cout<<"============================================\n";
// ---------------------------------------------------------
// Definitions
const float CAL_PER_MIN = 3.6;
for(int min=5; min<=30; min+=5){
// -----------------------------------------------------
// Within each iteration, we multiply the ratio by the
// iteration number starting from 5 to 30 because the
// burned calories are the same every 5 minutes.
// :::::::::::::::::::::::::::::::::::::::::::::::::::::
// NOTE we used the update part to increment by a 5 each
// time.
// :::::::::::::::::::::::::::::::::::::::::::::::::::::
// setw and setfill are for formatting only and defined
// in <iomanip> header.
// -----------------------------------------------------
cout<<"After running "<<setfill('0')<<setw(2)<<min
<<" minutes,\n";
cout<<"\tthe calories burned are "<< min*CAL_PER_MIN
<<"\n\n";
}
cout<<"============================================\n";
return 0;
}
--------------------------------------------------------------------------------------------------------------------------------------------
output