fork download
  1. //Castulo Jason Quintero CSC5 Chapter 3, P. 144, #7
  2. //
  3. /**************************************************************
  4.  *
  5.  * Compute total calories consumed
  6.  * ____________________________________________________________
  7.  * This program will compute total calories consumed from a
  8.  * bag of cookies.
  9.  *
  10.  * Computation is based on the formula:
  11.  * servings10 = cookiesinBag / 10
  12.  * serving1 = 300 / servings10
  13.  * cookies = serving1
  14.  * calories = cookies * cookiesAte
  15.  * ____________________________________________________________
  16.  * INPUT
  17.  * cookiesAte: Number of cookies consumed
  18.  *
  19.  * OUTPUT
  20.  * calories: Number of total calories consumed
  21.  *
  22.  **************************************************************/
  23. #include <iostream>
  24. #include <iomanip>
  25. using namespace std;
  26. //
  27. int main() {
  28. int cookiesinBag = 40;
  29. int servings10;
  30. int serving1;
  31. int cookies;
  32. int cookiesAte;
  33. int calories;
  34. //Input
  35. cout << "How many cookies have you eaten." << endl;
  36. cin>> cookiesAte;
  37. //Compute
  38. servings10 = cookiesinBag / 10;
  39. serving1 = 300 / servings10;
  40. cookies = serving1;
  41. calories = cookies * cookiesAte;
  42. //Output
  43. cout << "The total calories consumed were " << calories << "." << endl;
  44.  
  45. return 0;
  46. }
Success #stdin #stdout 0.01s 5292KB
stdin
5
stdout
How many cookies have you eaten.
The total calories consumed were 375.