A bag of cookies holds 40 cookies The calorie information on

A bag of cookies holds 40 cookies. The calorie information on the bag claims that there are 10 \"servings\" in the bag and that a serving equals 300 calories. Write a program that asks the user to input how many cookies that he/she ate and the report how many total calories were consumed. The cpp file name should be cookies.cpp

Solution

#include <iostream>
using namespace std;

int main() {
   double cookies, servings, calories;
   cout<< \"How many cookies did you eat?\";
   cin>>cookies;
   servings = cookies/4; // 1 serving has 4 cookies
   calories = 300 * servings; // i seving has 300 calories
   cout<<\"calories consumed: \"<<calories;
   return 0;
}

 A bag of cookies holds 40 cookies. The calorie information on the bag claims that there are 10 \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site