fork download
  1. //Issac Vallejo CSC5 Chapter 3, P. 143, #1
  2. //
  3. /**************************************************************
  4.  *
  5.  * COMPUTE HOW LONG A CAR CAN BE DRIVEN ON A FULL TANK OF GAS &
  6.  * HOW MANY MILES A GALLON OF GAS HAS.
  7.  * ____________________________________________________________
  8.  *This program computes a car's gas mileage
  9.  
  10.  * milespergallon = milespertank/numberofgallons
  11.  *____________________________________________________________
  12.  *INPUT
  13.  * GallonCapacity : Number of gallons a car can hold
  14.  *
  15.  * MaximumMiles : Number of miles a car can be driven on one
  16.   tank
  17.  *
  18.  *OUTPUT
  19.  *Miles : How many miles per gallon .
  20. **************************************************************/
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. int main() {
  25.  
  26. float gallonsCurrent; //INPUT - Max gallons per tank
  27.  
  28. float milesMAX; // INPUT - Max miles per tank
  29.  
  30. float milesPgallon; // OUTPUT - Number of miles per gallon
  31.  
  32. cout << "what is the maximum number of gallons your car can hold? " ;
  33.  
  34. cin >> gallonsCurrent;
  35.  
  36. cout << "what is the maximum amount of miles your can drive per tank? ";
  37.  
  38. cin >> milesMAX;
  39.  
  40. milesPgallon = milesPgallon/gallonsCurrent;
  41.  
  42. cout << "milesPgallon ";
  43.  
  44.  
  45. return 0;
  46. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
what is the maximum number of gallons your car can hold? what is the maximum amount of miles your can drive per tank? milesPgallon