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