Answer to Question #271249 in C++ for bushra khan

Question #271249

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


1
Expert's answer
2021-11-25T02:32:36-0500
#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);
}

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!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS