An internet service provider has three different subscription packages for its c
ID: 3629080 • Letter: A
Question
An internet service provider has three different subscription packages for its customers:Package A: For $9.95 per month, 10 hours of access are provided. Additional hours are $2.00 per hour.
Package B: For $13.95 per month, 20 hours of access are provided. Additional hours are $1.00 per hour.
Package C: For $19.95 per month, unlimited access are provided.
Write a program that calculates a customer's monthly bill. It should ask the user to enter the letter of the package the customer has purchased (A, B, or C) and the number of hours that were used. It should then display the total charges.
Now, modify the program you wrote for last question so it also calculates and displays the amount of money Package A customers would save if they purchased Packages 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.
Explanation / Answer
package internetserviceprovider; import javax.swing.JOptionPane; /** * * @author Home */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { char packageLetter; int hoursUsed; int regularHours; int additionalHours; double monthlyFee; double additionalHoursFee; double totalFee; String inputString; inputString = JOptionPane.showInputDialog("Enter the letter of the " + "package you purchased (either A, B, or C."); inputString = inputString.toUpperCase(); packageLetter = inputString.charAt(0); inputString = JOptionPane.showInputDialog("Enter the number of hours " + "you used."); hoursUsed = Integer.parseInt(inputString); switch(packageLetter) { case 'A': monthlyFee = 9.95; regularHours = 10; additionalHours = hoursUsed - regularHours; additionalHoursFee = additionalHours * 2.00; totalFee = monthlyFee + additionalHoursFee; JOptionPane.showMessageDialog(null,"The total charges is $" + totalFee + "."); break; case 'B': monthlyFee = 13.95; regularHours = 20; additionalHours = hoursUsed - regularHours; additionalHoursFee = additionalHours * 1.00; totalFee = monthlyFee + additionalHoursFee; System.out.println("The total charges is " + totalFee); JOptionPane.showMessageDialog(null,"The total charges is $" + totalFee + "."); break; case 'C': totalFee = 19.95; JOptionPane.showMessageDialog(null,"The total charges is $" + totalFee + "."); break; default: JOptionPane.showMessageDialog(null,"Plea… enter either A,B, " + "or 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.