Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This program is written in C language 1. Write a program that works for a travelling salesperson. The program calculates mileage reimbursement for a salesperson
This program is written in C language 1. Write a program that works for a travelling salesperson. The program calculates mileage reimbursement for a salesperson that travels for work at a rate of $.35 per mile. The program would also inform the salesperson of the gas mileage (mpg) of his vehicle. For this program you would need to create user defined functions. At the output, your program should interact with the user in this manner: MILEAGE REIMBURSEMENT AND MPG CALCULATOR Enter beginning odometer reading => 13505.2 Enter ending odometer reading => 13810.6 Enter gallons of gas consumed => 12 You traveled 305.4 miles. At $0.35 per mile, your reimbursement is $106.89. Your vehicle gas consumption is : 25.5 MPG a) Create a function prototype for the function that accepts two double-types (begin and end odometer reading), and returns the miles travelled as a double type. b) Create another function prototype for a function that accepts the miles travelled as a double type and returns the reimbursement value. c) Create a third function prototype for a function that accepts two inputs (miles travelled and number of gallons of gas consumed) and return the mile-per-gallon (mpg) of the vehicle d) Create a fourth function proto for a function that accepts three inputs (miles travelled, reimbursement and MPG of the vehicle). The function does not return anything. It only prints and displays the results on the screen. e) Function 1 definition: The function should accept two double types and return the difference of those values. f) Function 2 definition: The function should take the miles travelled and calculate the reimbursement amount based on the reimbursement rate of $0.35/ mile. g) Function 3 definition: The function should take the miles travelled and number of gallons of gas consumed and return the gas consumption of the vehicle in mile-per-gallon (mpg). h) Function 4 definition: The function should print the 3 inputs as follows: You traveled 305.4 miles. At $0.35 per mile, your reimbursement is $106.89. Your vehicle gas consumption is : 25.5 MPG i) In the main function, your program should interact with the user and prompt the user for inputs first. Enter beginning odometer reading => 13505.2 Enter ending odometer reading => 13810.6 Enter gallons of gas consumed => 12 j) Use function calls to calculate the miles travelled, reimbursement value and MPG of the vehicle. The function calls should come in an orderly manner and return calculation results. Make sure the returned values are stored in appropriate variables to avoid loss of information. k) Finally, use the fourth function to display the information
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started