/* Travel.c */
/* Travel Efficiency */
/* Programmer: Jonathan Kleid */
/* 
/* Purpose: Calculates miles per gallon and price per mile when */
/* given miles traveled, number of gallons used, and gas price. */

#include <stdio.h> /* necessary for scanf() and printf() functions */

main()
{
  /* Variable declarations */
  float MilesTraveled;     /* stores number of miles */
  float GallonsUsed;       /* stores number of total gallons used */
  float PricePerGallon;    /* stores price per gallon */
  float PricePerMile;      /* stores the price per mile */
  float MilesPerGallon;    /* stores the number of miles per gallon */

  /* Ask user for input values. */
  printf("How many miles did you travel? ");
  scanf("%f", &MilesTraveled);
  printf("How many gallons of gas did you use? "); 
  scanf("%f", &GallonsUsed);
  printf("How much did one gallon of gas cost? $"); 
  scanf("%f", &PricePerGallon);   

  /* Divide the number of miles by the number of gallons to get MPG. */
  MilesPerGallon = MilesTraveled / GallonsUsed;

  /* Divide price per gallon by miles per gallon */
  /* to get price per mile. */
  PricePerMile = PricePerGallon / MilesPerGallon;

  /* Output miles per gallon and price per mile. */
  printf("You got %.2f miles per gallon\n", MilesPerGallon); 
  printf("and each mile cost $%.2f.\n", PricePerMile);
  
  return 0;
}
