In: Computer Science
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $ 0.35 per mile. Your program should interact with the user in this manner:
MILEAGE REIMBURSEMENT CALCULATOR
Enter beginning odometer reading: 13505.2
Enter ending odometer reading : 13810.6
You traveled 305.40 miles.
At $ 0.35 per mile, your reimbursement is $ 106.89.
The values in red color are inputs for the program.
The values in blue color are results of expressions.
Source_code:
#include <iostream> //Header file
using namespace std;
//This tells the compiler to use std namespace
library
int main()
//Main function
{
float miles, odometer1, odometer2, reimbursement,
rate;
//variables declaration
printf("MILEAGE REIMBURSEMENT
CALCULATOR.\n");
//printf
function
printf("Enter the beginning odometer
reading:>");
scanf("%f", &odometer1);
printf("\nEnter the ending odometer
reading:>");
scanf("%f", &odometer2);
miles = odometer2 - odometer1;
printf("\nSalesperson traveled %6.2f", miles);
rate = 0.35;
reimbursement = miles * rate;
//reimbursement
calculation
printf("\nTotal owed reimbursement is $%6.2f",
reimbursement);
getchar();
return 0; //to pause the final output
}
Source_code_images:
Output:
MILEAGE REIMBURSEMENT CALCULATOR.
Enter the beginning odometer reading:>13505.2
Enter the ending odometer reading:>13810.6
Salesperson traveled 305.40
Total owed reimbursement is $106.89
Output_images: