fork(1) download
  1. // Nicolas Ruano CS1A Chapter 3 Pp. 144 # 7
  2. /******************************************************************************
  3.  *****************************************************************************/
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. int main() {
  8. const int COOKIES_PER_BAG = 40;
  9. const int SERVINGS_PER_BAG = 10;
  10. const int CALORIES_PER_SERVING = 300;
  11.  
  12. // Calculate calories per cookie
  13. int caloriesPerCookie = (CALORIES_PER_SERVING * SERVINGS_PER_BAG) / COOKIES_PER_BAG;
  14.  
  15. int cookiesEaten;
  16. cout << "How many cookies did you eat? R:/ 5 cookies\n";
  17. cin >> cookiesEaten;
  18.  
  19. int totalCalories = cookiesEaten * caloriesPerCookie;
  20.  
  21. cout << "You consumed approximately 375" << totalCalories << " calories." << endl;
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
How many cookies did you eat? R:/ 5 cookies
You consumed approximately 3752457450 calories.