fork download
  1. /**********************************************************************************
  2.  * PROGRAMMED BY : DAISY CONTRERAS
  3.  * CLASS : CSC 5
  4.  * SECTION : MW 2:20-5:30PM
  5.  * ASSIGNMENT : CHAPTER 2 QUESTION #10
  6.  **********************************************************************************
  7.  *
  8.  * COMPUTE THE NUMBER OF MILES A CAR CAN BE DRIVEN BY THE GALLON
  9.  * ________________________________________________________________________________
  10.  * This program computes the miles a car can be driven given the miles driven and
  11.  * and the gallons of gas it has.
  12.  
  13.   Computation is based on the formula :
  14.   Miles per gallon = miles driven / gallons of gas in capacity
  15.   ________________________________________________________________________________
  16.  
  17.   INPUT
  18. car_gallon_gas : amount of gallons of gas a car has in capacity
  19. miles_driven : miles were driven
  20.  
  21.   OUTPUT
  22. miles_per_gallon : miles that can be driven based on the number of gallons
  23. *
  24. * ********************************************************************************/
  25.  
  26.  
  27. #include <iostream>
  28. using namespace std;
  29.  
  30. int main() {
  31. //This program calculates the number of miles per gallon a car gets
  32.  
  33. float car_gallon_gas; //INPUT gallons of gas a car has
  34. float miles_driven; //INPUT miles that were driven
  35. float miles_per_gallon; //OUTPUT miles that can be driven by full tank capacity
  36.  
  37. // Compute the gallons of gas a car has in full capacity
  38. car_gallon_gas = 12;
  39.  
  40. // Define the miles that can be driven at full tank capacity
  41. miles_driven = 350;
  42.  
  43. // Compute the MPG
  44. miles_per_gallon = miles_driven / car_gallon_gas;
  45.  
  46. // Display the miles per gallon a car can be driven
  47. cout << miles_per_gallon << " Miles Per Gallon (MPG)" << endl;
  48.  
  49. return 0;
  50. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
29.1667 Miles Per Gallon (MPG)