Question
Modify the program below so it also calculates and displays the amount of money Package A customers would save if they purchased Package B or
Modify the program below 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.
import java.util.*;
public class Lab2 { public static void main (String[] args) { //scanner Scanner input = new Scanner(System.in); //declarations int hours; char pack; double totalCharges = 0; //inputs System.out.println("Enter the letter of the package purchased (A, B, or C):"); pack = input.next().charAt(0); System.out.println("Enter the hours worked:"); hours = input.nextInt(); //switch Statements switch (pack) { case 'A': { totalCharges = 9.95; if (hours > 10) totalCharges += (hours - 10) * 2; } break; case 'B': { totalCharges = 13.95; if (hours > 20) totalCharges += (hours - 10) * 1; } break; case 'C': { totalCharges = 19.95; } break; default: System.out.println("Incorrect Package...please choose A,B, or C."); } System.out.printf("The monthly bill on the package " + pack + " is: $%.2f ", totalCharges); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started