fork download
  1. // Marvyn De La Torre CS1A Chapter 3, P.143, #1
  2.  
  3. /************************************************************
  4. // Calculate Miles per Gallon
  5. //
  6. // This program will display the miles per gallon of the user's car.
  7. //
  8. // Input:
  9. // Miles driven = miles
  10. // Gallons of Gas = gas
  11. //
  12. // Output:
  13. // Miles per Gallon = mpg
  14. *************************************************************/
  15.  
  16. #include <iostream>
  17. using namespace std;
  18.  
  19. int main()
  20. {
  21. double gas; // Dictionary of variables
  22. double miles;
  23. double mpg;
  24.  
  25. cin >> gas;
  26. cin >> miles;
  27.  
  28. mpg = miles / gas;
  29.  
  30. cout << "The total mpg is " << mpg;
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 5304KB
stdin
15
450
stdout
The total mpg is 30