Modify the program you wrote so it also calculates and displays the amount of mo
ID: 3755754 • Letter: M
Question
Modify the program you wrote so it also calculates and displays the amount of money Package A customers would save if they purchased Package B or C, and the amount of money Package B customers would save if they purchased Package C. If there would be no savings, no message should be printed. This is what I have so far . I need to use SWITCH AND IF statements like I did. Only using the scanner class no advanced java at all. I think my problem is in my switch and if statements . It is not doing the calculations for savings for the choosing the different packages. public dass InternetServiceProvider 2 public static void main(Stringl args) String userinput double totalSavingsAloB (packageA 13.95) lotalSavingsAloC (packageA 19.95) Scanner keyboard new ScannerlSystem.in package have you obtain? (Please use A, B, or C7 userinput# keyboard.netine0: case A. Syatem.outprintinl What are the total amount of hours used for this month? otalHours keyboard.nextDouble): packageA 9.95 totalHours, System ut print-For Package AinThe total dages for this month is S·· package SystemoutprintreYou save a total of . . ktaisaingatoa +-f you chose Package Ber + "and you would have save attal of. asa dngsNaC . "Ifyu chose Package C." else packageA. 9.95·bea ours. 2.00: System.out.printFor Package A-inThe total charges for this month is $packageA) ctalSavingsAtoB (packageA 13.9) totalsanngAOC= (packageA. 19.95); Systermout printrnYou save a total of . + wasavingAb- you chose Package Ba. totaSavingsAtoC+it you + "and you would have save a total of" chose Package C.'k break English (USA) INSRT STDExplanation / Answer
Answer:
import java.io.*;
import java.util.Scanner;
import java.text.DecimalFormat;
class InternetProviderPart2
{
public static void main(String[] args)
{
int hours;
double packageA_amount,
packageB_amount,packageC_amount;
double total_amount=0;
DecimalFormat formatter =
new DecimalFormat(" 0.00");
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter hours:");
hours=keyboard.nextInt();
if(hours<10)
packageA_amount=9.95;
else
packageA_amount=9.95+((hours-10)*2);
if(hours<20)
packageB_amount=14.95;
else
packageB_amount=14.95+((hours-20)*1);
packageC_amount=19.95;
double difference;
difference=packageA_amount- packageB_amount;
System.out.println("Package A customer would save $"
+formatter.format(difference)+ " than Package B");
difference=packageA_amount - packageC_amount;
System.out.println("Package A customer would save $"
+formatter.format(difference)+ " than Package C");
difference=packageB_amount - packageC_amount;
System.out.println("Package B customer would save $"
+formatter.format(difference)+ " than Package C");
System.exit(0);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.