//Kanoa Holden CS1A Chapter 3, P. 144 Q#7
//
/*******************************************************************************
*
* COMPUTE CALORIES ATE FROM NUMBER OF COOKIES
* _____________________________________________________________________________
* This program calculates the calories consumed based on the number of cookies
* ate.
* _____________________________________________________________________________
* INPUT
* total_cookies : total amount of cookies ate
* servings : serving size of cookies
* calories_per_serving : the amount of calories per serving of cookies
*
* OUTPUT
* total_calories : total amount of calories consumed
*
******************************************************************************/
#include <iostream>
using namespace std;
int main() {
// Constants for total cookies, servings, and calories per serving
const int total_cookies = 40;
const int servings = 10;
const int calories_per_serving = 300;
// Calculate how many cookies are in each serving
int cookies_per_serving = total_cookies / servings;
// Ask the user how many cookies they ate
int cookies_eaten;
cout << "\nEnter the number of cookies you ate: ";
cin >> cookies_eaten;
// Calculate how many calories were consumed
double calories_per_cookie = static_cast<double>(calories_per_serving) / cookies_per_serving;
double total_calories = cookies_eaten * calories_per_cookie;
// Display the total calories consumed
cout << "\nYou consumed " << total_calories << " calories." << endl;
return 0;
}