# How to write a program that calculates mileage reimbursement for a salesperson at a rate of \$.45 per mile. The program should interact with the user in this manner:MILEAGE REIMBURSEMENT...

How to write a program that calculates mileage reimbursement for a salesperson at a rate of \$.45 per mile.

The program should interact with the user in this manner:
MILEAGE REIMBURSEMENT CALCULATOR
You traveled 305.4 miles. At \$0.45 per mile,

tiburtius | High School Teacher | (Level 2) Educator

Posted on

The program:

#include<stdio.h>
int main()
{
float b,e;
scanf("%f",&b);
scanf("%f",&e);
printf("\nYou traveled %.2f. At \$0.45 per mile, your reimbursement is %.3f.",e-b,(e-b)*0.45);
return 0;
}

You could also allow the user to input price per mile by adding these two lines:

printf("\nEnter price per mile=>");
scanf("%f",&p);

also you would have to change the last printf to

printf("\nYou traveled %.2f. At \$%f per mile, your reimbursement is %.3f.",e-b,p,(e-b)*p);

Of course you would have to add p to line 4 of the original code.