Create an application that calculates your daily driving cost, so that you can e
ID: 3806096 • Letter: C
Question
Create an application that calculates your daily driving cost, so that you can estimate how much money could be saved by car pooling. The application should input the following information and display the user's cost per day of driving to work:
1. Total miles driven per day.
2. Cost per gallon of gasoline.
3. Average miles per gallon.
4. Parking fees per day.
5. Tolls per day.
Be sure that in your program you considers the following:
Your program should include:
1. proper case, variable names(meaningful and use conventions)
2. proper organization, indentation, white space, and comments
3. Has the right inputs and outputs, computes correct results . is efficient
In C Programming please and thank you
Explanation / Answer
#include<stdio.h>
int main()
{
int miles,gasoline_cost,MilesPerGallon,ParkingFee,Tolls;
int TotalCostPerDay;
//Prompting the user to enter the following costs
printf("Enter the following: ");
printf("1. Total miles driven per day. ");
printf("2. Cost per gallon of gasoline. ");
printf("3. Average miles per gallon. ");
printf("4. Parking fees per day. ");
printf("5. Tolls per day. ");
//Reading the user input
scanf("%d%d%d%d%d",&NumberOfMiles,&GasolineCost,&MilesPerGallon,&ParkingFee,&Tolls);
//calculating the total cost per day
TotalCostPerDay = ((NumberOfMiles/MilesPerGallon)*GasolineCost) + ParkingFee + Tolls;
//displaying the output
printf("Total Cost per day: %d ",TotalCostPerDay);
return 0;
}
Output:
Enter the following:
1. Total miles driven per day.
2. Cost per gallon of gasoline.
3. Average miles per gallon.
4. Parking fees per day.
5. Tolls per day.
500
20
2
10
100
Total Cost per day: 160
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.