Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fuel Reward Points Develop a program that calculates charges for a fuel reward p

ID: 3905299 • Letter: F

Question

Fuel Reward Points Develop a program that calculates charges for a fuel reward points subscription. Subscription A is the most affordable if you plan on driving less than 1000 miles, however, if you drive over 1000 miles, you are charged for each mile after that. Subcription B is if you plan on driving over 5000 miles, and you are charged for each mile after. Subscription C is for unlimited miles, you just have to pay a higher flat fee The program will require some validity checking * * The user must enter a character corresponding to the chosen subscription. If any character other than ('A', 'a', 'B', 'b', 'C', or 'c') is input then the program displays an appropriate message and will prompt the user for a new plan selection. The program will continue to prompt the user until a valid plan is selected. You may assume that the user will only enter a single character. The user must input the number of miles used; it must be between 0 and 30,000 (inclusive). If a value outside of this range is input then the program provides an appropriate message and will request a new entry. You may assume that the user will only enter integer numbers o o The plan details are as follows: » Package Base Price $50 $100 $250 Additional Fees $.03 for each mile after 1000 miles S.01 for each mile after 5000 miles Unlimited data The program will let the user know how much money they save by upgrading. (plan A to B, C to A, etc.) and will display the potential savings of switching. The factor for upgrades is as follows: Package Decision point $100 $250 $250 Cost savings cost of A cost of B cost of A cost of GC cost of B cost of

Explanation / Answer

import java.util.Scanner;
class Bill
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String ch; //variable declaration
double total=0.0,diff=0.0,tot=0.0;
double tp=0,miles;
//menu for the user
System.out.println("Package Base Price Additional Fees");
System.out.println("A $50 $0.03 for each miles after 1000");
System.out.println("B $100 $0.01 for each miles after 5000");
System.out.println("C $250 Unlimied");
do
{
System.out.println("Enter a plan to choose");
ch=sc.nextLine(); //accepting value from user
}while(ch!="a" || ch!="A" || ch!="b" || ch!="B" || ch!="c" || ch!="C");
do
{
System.out.println("Enter total miles");
miles=sc.nextDouble();//accepting value from user
}while(miles>30000);
if(ch =="a" || ch=="A") //if choice is A
{
tp=miles-1000;
total=(50+tp*0.03);
  
}
if(ch =="b" || ch=="B") //if choice is B
{
tp=miles-5000;
total=(100+tp*0.01);
}
if(ch =="c" || ch=="C") //if choice is C
{
total=250;
}
//displaying the result
System.out.println("You have choosen Plan "+ch);
System.out.println("Total Cost for "+miles+" miles is $"+total);
if((ch == "a" || ch=="A") && total > 100)
{
tp=miles-5000;
tot=(100+tp*0.01);
diff=total-tot;
System.out.println("If you switch to Plan B then you can save $"+diff);
}
if((ch == "a" || ch=="A") && total > 250)
{
diff=total-250;
System.out.println("If you switch to Plan C then you can save $"+diff);
}
if((ch == "b" || ch=="B") && total > 250)
{
diff=total-250;
System.out.println("If you switch to Plan C then you can save $"+diff);
}
}
}