fork download
  1. //Ryan Shahriyarpour CS1A Carl Argila CH3 HW Q:7
  2. //
  3. /*****************************************************************************
  4.  *
  5.  * How Many Calories Eaten Total
  6.  *
  7.  *
  8.  *
  9.  * *********
  10.  *
  11.  * The goal is to calculate total calories consumed based on cookies eaten
  12.  *
  13.  * Calories Per Cookie = Total Calories / Total Cookies
  14.  * Total Calories Consumed = Cookies Eaten * Calories Per Cookie
  15.  *
  16.  *
  17.  *
  18.  *
  19.  * ************
  20.  *
  21.  *
  22.  *
  23.  * INPUT
  24.  * cookiesEaten : number of cookies the user ate
  25.  *
  26.  * OUTPUT
  27.  * totalCalories : amount of total calories consumed
  28.  *
  29.  ****************************************************************************/
  30.  
  31. #include <iostream>
  32. using namespace std;
  33.  
  34. int main() {
  35. int cookiesEaten;
  36. double totalCalories;
  37.  
  38. cout << "How many cookies did you eat? ";
  39.  
  40. // Store input in variable
  41. cin >> cookiesEaten;
  42.  
  43. // calculate
  44. totalCalories = cookiesEaten * (300.0 / 40.0);
  45.  
  46. // Display the result
  47. cout << "Total calories consumed: " << totalCalories << endl;
  48.  
  49. return 0;
  50. }
  51.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
How many cookies did you eat? Total calories consumed: 245730