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.
My code is wrong because when i started it, it gave me wrong and weird result. Can anyone help me rewrite it correctly?
I compiled an ran ran correctly, for me, though it calculated and showed the total calories burnt, every minute. You should put a if statement to show the results, ONLY if i is equal to the minutes desired. Also, you could declare double calories, after your int i declaration, and calculate the calories in the do loop , without the added 'double' declaration.
I am learning about the "loop" and it really hard. So that is how you write a loop, because when i did this for the first time he said i was so wrong.
#include<iostream>
using namespace std;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int main()
{
int i,n;
char ch;
double cal;
do
{
cin>>n;
cal=n*3.90;
cout<<cal<<endl;
cout<<"want to continue: Y or N\n";
cin>>ch;
}while(ch=='Y');
return 0;
}
it worked but i gotta keep punching in values everytime and he does't told the class what is he expecting. :(