I need help with my Java homework!

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 charges.

Modify the program so it calculates and displays the amount of money Packaage 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.

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 acess is provided.

import java.util.Scanner;

import java.text.DecimalFormat;
public class Bill{
public static void main(String[] args){
String input;
char servicePackage;
int hours=0;
int extrahours=0;
double charges=0.0;
int totalHours = 0;
final double BASE_RATE_A = 9.95;
final double BASE_RATE_B = 13.95;
final double BASE_RATE_C = 19.95;
final int BASE_HOUR_A = 10;
final int BASE_HOUR_B = 20;
final double PER_HOUR_A = 2.00;
final double PER_HOUR_B = 1.00;

Scanner kb = new Scanner(System.in);
DecimalFormat fmt = new DecimalFormat("$##.00");

System.out.print("Service package (A, B, or C): ");
input = kb.nextLine();
servicePackage = input.charAt(0);

if(servicePackage == 'A'){
System.out.print("Number of hours: ");
hours = kb.nextInt();
if(hours<=10){
charges = BASE_RATE_A;
System.out.println("Total Charges: "+fmt.format(charges));
}
else{
extrahours=hours-BASE_HOUR_A;
charges = BASE_RATE_A +(extrahours*PER_HOUR_A);
System.out.println("Total Charges: "+fmt.format(charges));
}
}
else if(servicePackage == 'B'){
System.out.print("Number of hours: ");
hours = kb.nextInt();
if(hours<=20){
charges = BASE_RATE_B;
System.out.println("Total Charges: "+fmt.format(charges));
}
else{
extrahours=hours-BASE_HOUR_B;
charges = BASE_RATE_B+(extrahours*PER_HOUR_B);
System.out.println("Total Charges: "+fmt.format(charges));
}

}
else if(servicePackage == 'C'){
System.out.print("Number of hours: ");
hours = kb.nextInt();
charges = BASE_RATE_C;
System.out.println("Total Charges: "+fmt.format(charges));
}

}
}

==

hope this helps

THANKS!

but how would I do the second part?

"Modify the program so it calculates and displays the amount of money Packaage 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."

thanks,

Matt

I need help with my Java homework!

Write a program that calculates a customer's monthly bill. It should ask the user via dialog box 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 charges in a dialog box. The input and out put must be done using the dialog boxes.

Modify the program so it calculates and displays the amount of money Packaage 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.

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 acess is provided.

1. A local Satellite Television Company has assigned you to write an application that can calculate a customer’s monthly bill. There are two types of customers: Residential (has only one service connection) and Business (has one or more connections). Both customer types can subscribe to any number of premium channels. The monthly billing amount is the total of basic service fee plus the premium channels charge. The rates for the two customer types are as follows:

Basic Service Fee Premium Channels Charge
Residential RM20.00
RM7.50 per channel
Business RM75.00 for the first 10 connections; RM10 for each additional connection RM20.00 per channel for any number of connections

To solve this problem, you can follow these steps:

1. Ask the user to enter the letter of the package (A, B, or C).
2. Ask the user to enter the number of hours used.
3. Based on the user input, calculate and display the charges for the given package.

Here's an example solution in Java:

```java
import java.util.Scanner;

public class MonthlyBillCalculator {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

// Step 1: Get the package letter from the user
System.out.print("Enter the package letter (A, B, or C): ");
String packageLetter = input.nextLine().toUpperCase();

// Step 2: Get the number of hours used from the user
System.out.print("Enter the number of hours used: ");
int numHours = input.nextInt();

// Step 3: Calculate and display the charges for the given package
double charges = 0.0;

switch (packageLetter) {
case "A":
charges = 9.95 + Math.max(0, numHours - 10) * 2.0;
System.out.println("Charges for Package A: $" + charges);
double savingsAtoB = (13.95 + Math.max(0, numHours - 20) * 1.0) - charges;
double savingsAtoC = 19.95 - charges;

if (savingsAtoB > 0) {
System.out.println("Package A customers can save $" + savingsAtoB + " by switching to Package B.");
}
if (savingsAtoC > 0) {
System.out.println("Package A customers can save $" + savingsAtoC + " by switching to Package C.");
}
break;

case "B":
charges = 13.95 + Math.max(0, numHours - 20) * 1.0;
System.out.println("Charges for Package B: $" + charges);
double savingsBtoC = 19.95 - charges;

if (savingsBtoC > 0) {
System.out.println("Package B customers can save $" + savingsBtoC + " by switching to Package C.");
}
break;

case "C":
charges = 19.95;
System.out.println("Charges for Package C: $" + charges);
break;

default:
System.out.println("Invalid package letter. Please enter A, B, or C.");
break;
}

input.close();
}
}
```

This program uses a `switch` statement to calculate the charges for each package based on the input package letter. It also calculates the potential savings for Package A customers if they switch to Package B or C, and the potential savings for Package B customers if they switch to Package C. If there are no savings, the program does not print any savings message.