fork download
  1. /******************************************************************************
  2.  * AUTHOR : Aiden Stannard *
  3.  * STUDENT ID : 1284603 *
  4.  * Ch3, p143, #4 : Miles Per Gallon Calc *
  5.  * CLASS : CS1A *
  6.  * SECTION : T/Th 6PM - 8:20PM *
  7.  * DUE DATE : 9/12/2026 *
  8.  ******************************************************************************/
  9. /******************************************************************************
  10.  * CALCULATE CAR FUEL ECONOMY
  11.  * ____________________________________________________________________________
  12.  * This program Calculates the fuel economy of a users car by prompting the user
  13.  * to enter their car's fuel capacity and range in units of MILES and GALLONS
  14.  *
  15.  * Computation is based on the formula: GALLONS / MILES = MPG
  16.  * __________________________________________________________________________
  17.  * INPUT
  18.  * Enters the fuel capacity of your cars tank in gallons:___
  19.  * Enter the max range of your car on a full tank in miles:___
  20.  *
  21.  *OUTPUT
  22.  * Your car has an estimated fuel economy of:___ Miles Per Gallon
  23.  *
  24.  ******************************************************************************/
  25. #include <iostream>]
  26. using namespace std;
  27. int main()
  28. {
  29. float fuelCap; // The Amount of fuel the car can hold (Gallons)
  30. float carRange; // How far the vehcile can travel on a full tank (Miles)
  31. float MPG; // Miles Per Gallon Value
  32.  
  33. cout << "Enters the fuel capacity of your cars tank in gallons: \n";
  34. cin >> fuelCap;
  35. cout << "Enter the max range of your car on a full tank in miles: \n";
  36. cin >> carRange;
  37. MPG = carRange / fuelCap;
  38. cout << "Your car has an estimated fuel economy of: " << MPG
  39. << " Miles Per Gallon";
  40. return 0;
  41. }
Success #stdin #stdout 0s 5320KB
stdin
12
500
stdout
Enters the fuel capacity of your cars tank in gallons: 
Enter the max range of your car on a full tank in miles: 
Your car has an estimated fuel economy of: 41.6667 Miles Per Gallon