Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

if -else statement .c program enter in three values: 1. The average miles per ga

ID: 3849760 • Letter: I

Question

if -else statement .c program

enter in three values: 1. The average miles per gallon for their vehicle, 2. the price of a gallon of gas, and 3. how much money then have with them at that time. You will output how many miles they can drive before they run out of money and gas. Also, you will output the number of times they had to stop for gas. You will make the following assumptions: All vehicles have exactly a 25-gallon gas tank. Before a trip begins the vehicle’s gas tank is full. During the trip no extra money is found or earned. No credit cards or loans.

Explanation / Answer

#include <stdio.h>

int main(void) {
   // your code goes here
   int fueltankcapacity=25;
   int avgmiles;
   int price;
   int money;
   int ridedistance;
   int finalride;
   int finalever;
   printf("enter average miles per gallon for their vechicle=");
   scanf("%d",&avgmiles);
   printf("enter price of gallon of gas=");
   scanf("%d",&price);
   printf("enter how much mony they have with them=");
   scanf("%d",&money);
   ridedistance=avgmiles*fueltankcapacity;
   printf("At starting fuel tank is full so he can ride upto=%d miles",ridedistance);
   printf("After this distance vechicle stops and now he left with %d",money);
   finalride=money/price;
   printf("with this money he can fill his gas tank up %d",finalride);
   finalever=finalride*avgmiles;
   printf("finally he stops after %d",finalever);
  
   return 0;
}

output:

enter average miles per gallon for their vechicle=45
enter price of gallon of gas=70
enter how much mony they have with them=200
At starting fuel tank is full so he can ride upto=1125 miles
After this distance vechicle stops and now he left with 200
with this money he can fill his gas tank up 2
finally he stops after 90

//initially price,gas cost and money with he had taken from user.

//at firrst he had tank full of gas ..and with the inputs we calculated the end ride with gas already he having.and now he stops at particular miles.and he will fill gas with limited money he had and we again calculated distance he can travel at last