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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!