# computer science

posted by .

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.

• computer science -

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

• computer science -

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

• computer science -

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.

## Similar Questions

1. ### C Programming

Write a program that prompts the user to enter a temperature, followed by a letter representing Celsius (C) or Fahrenheit (F). Then prompt the user for the conversion type and print the results to the screen with one decimal point. …
2. ### computer science

write a program that calculates a customer's monthly bill. it should input customer name, which package the customer has purchased, and how many hours were used. it should then create a bill that includes the input informtion and the …
3. ### programming and visual basic

These are two different types of questions, these are not the same questions The Some interest Credit Company provides loans to customers at 1.5 percent interest per month. Design an application that gets customer account data that …
4. ### computer science

I need to write a program that ask the student to enter an answer to a math problem. The user should enter two values, one at a time, and then ask for an answer. The program should display if the entered answer is correct or not and …
5. ### programming

Write a program which allows user to enter 10 student names and scores for Java programming 1 and Java programming 2. Allow user to choose which course they want to enter the record for. Use the loop to ask input from user. The program …
6. ### intro to computer programming

Write a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount. Your program should use a loop …
7. ### intro to computer programming

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 …
8. ### java programming

the learner is asked to write a program using java with user input that caculate and displays, the number of months it will take the user to save an amount of money. the user must enter the
9. ### computer science

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 …
10. ### computer science

Internet Service Provider 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 …

More Similar Questions