A bag of cookies holds 40 cookies. The calorie information on the bag claims that the bag contains 300 calories. Write a program that asks the user to input that how many cookies he or she actually ate and then report how many calories were consumed
#include<iostream>
using namespace std;
int main()
{
const int bag=40;
const int calOnBag=300;
const double calOnCok=(double)300/40;
int cook;
do
{
cout<<"How many cookies did you eat? (0-exit)\n";
cout<<"Your input: ";
cin>>cook;
if(cook==0)break;
cout<<cook*calOnCok<<" calories were consumed\n";
}while(true);
}
Comments
Leave a comment