In: Computer Science
***Please answer the question using the JAVA programming language.
Write a program that calculates mileage reimbursement for a salesperson at a rate of $0.35 per mile. Your program should interact (ask the user to enter the data) with the user in this manner:
MILEAGE REIMBURSEMENT CALCULATOR
Enter beginning odometer reading > 13505.2
Enter ending odometer reading > 13810.6
You traveled 305.4 miles. At $0.35 per mile, your reimbursement is $106.89.
** Extra credit 6 points: Format the answer (2 points), use JavaDoc (2 points), use constant for the rate per mile (2 points).
import java.util.Scanner;
public class Main {
// Constant to represent the rate per mile
private static final double RATE_PER_MILE = 0.35;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("MILEAGE REIMBURSEMENT CALCULATOR");
// take the readings
System.out.print("Enter beginning odometer reading > ");
double startReading = sc.nextDouble();
System.out.print("Enter ending odometer reading > ");
double endReading = sc.nextDouble();
// calculate the number of miles travelled
double miles = endReading - startReading;
// calculate the total reimbursement
double reimbursement = miles * RATE_PER_MILE;
// print the results
System.out.printf("You traveled %.2f miles. At $%.2f per mile, your reimbursement is $%.2f.", miles, RATE_PER_MILE, reimbursement);
}
}