The first step in writing any program is to develop the algorithms (sets of instructions) needed.
For the number of miles travelled:
- Get Beginning Odometer Reading;
- Get Ending Odometer reading;
- Total Miles = Ending Odometer Reading - Beginning Odometer Reading
For the amount of Reimbursement:
- Get the Reimbursement Rate;
- Reimbursement = Total Miles * Reimbursement Rate;
For the actual program we need to:
- Include the standard Input/Output Header file that will handle inputs from the keyboard and outputs to the screen.
- Open our main() function (Note that the main() function is not normally used to hold the complete program but since this is a very simple program separate functions will not be needed).
- Declare our variables
- Get user input (normally, checking would be done to make sure the user put in expected information)
- Perform calculations (in this case, assuming all inputs are correct)
- Send output to the screen
- End program