fork download
  1. //Eesha Tangirala #CS1A Chapter 3, pg. 144, #7
  2.  
  3. //****************************************************************************
  4. //Calculate Calories
  5.  
  6. //____________________________________________________________________________
  7. //Use the number of cookies that the user eats
  8. //to determine the number of calories they ate
  9. //____________________________________________________________________________
  10.  
  11. //INPUT
  12. //# of cookies eaten
  13. //OUTPUT
  14. //# of calories consumed
  15.  
  16. //****************************************************************************
  17.  
  18. #include <iostream>
  19. #include <iomanip>
  20.  
  21. using namespace std;
  22.  
  23. int main() {
  24. ////Calories per cookie = 75
  25. float cookies, calories;
  26.  
  27. cout << "How many cookies did you eat?" << endl;
  28.  
  29. cin >> cookies;
  30. calories = cookies * 75;
  31.  
  32. cout << "You consumed " << calories << " calories" << endl;
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0s 5312KB
stdin
5
stdout
How many cookies did you eat?
You consumed 375 calories