#include <stdio.h>
int main (int argc, const char * argv[]) {
float miles;
float gallons;
float price;
float mpg;
float ppm;
float totalMiles;
float totalGallons;
float totalPrice;
int text;
printf ("Hello, what would you like to do?\n");
printf ("1 - enter miles\n");
printf ("2 - enter gallons\n");
printf ("3 - enter price\n");
printf ("4 - see summary\n");
printf ("5 - exit\n");
switch (scanf ("%i", &text))
{
case 1:
{
printf ("Hello, enter miles driven- ");
scanf ("%f", &miles);
totalMiles += miles;
}
case 2:
{
printf ("Hello, enter gallons used- ");
scanf ("%f", &gallons);
totalGallons += gallons;
}
case 3:
{
printf ("Hello, enter price paid- ");
scanf ("%f", &price);
totalPrice += price;
}
case 4:
{
mpg = miles/gallons;
ppm = price/miles;
printf("You drove %.2f miles.\n", miles);
printf("You used %.3f gallons.\n", gallons);
printf("You paid $%.2f\n", price);
printf("You got %.2f miles per gallon.\n", mpg);
printf("You got $%.2f per mile\n", ppm);
}
case 5:
printf("Goodbye");
break;
}
return 0;
}