Steve W.

asked • 07/24/17

can you see why this code is skiping and will not set the following value: distancecharge = distance * 1.8;

int main(void){

int num_passengers;
float distance, fare, distancecharge, passengercharge, airportsurcharge;
char airportride;
printf("Cab fare calculator program: modified by Steve Walker");
printf("\nEnter number of passengers: ");
scanf("%i", &num_passengers);
printf("Enter distance measured by tenth of mile: ");
scanf("%f", &distance);
printf("Going to the airport Y/N");
scanf(" %c", &airportride);
distancecharge = distance * 1.8;
if(num_passengers == 1);
passengercharge = 0;
if (num_passengers == 2);
passengercharge = 1;
if (num_passengers > 2);
passengercharge = 1 +(.5 * num_passengers -1);
if (airportride == 'Y')
airportsurcharge = 2;
else
airportsurcharge = 0;
if (fare < 5);
fare = 5;
printf("\nEnter your distance charge for this ride is $%.2f\n,airportsurcharge");
printf("Your passenger charge for this ride is $%.2f\n, passengercharge");
printf("Your airport surcharge for this ride is $%.2f\n");
printf("Your total fare for this ride is $%.2f");
fare;
printf("Have a nice day");

return 0;

}
 the code above seems to be correct except it is not setting the value for the last question and jumps to the end without any values

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.