computer science

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.

  1. 👍 0
  2. 👎 0
  3. 👁 1,334
  1. 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

    1. 👍 0
    2. 👎 0
  2. 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

    1. 👍 0
    2. 👎 0
  3. 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. 👍 0
    2. 👎 0
  4. 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

    1. 👍 0
    2. 👎 0

Respond to this Question

First Name

Your Response

Similar Questions

  1. Pseudocode

    Write pseudocode for a program that calculates a customer’s total price after tax. The program will ask the user for the price of the item they are buying. Then the program will add a 5% tax to the item and output the final

  2. Algebra

    A phone company offers two monthly charge plans. In Plan A, the customer pays a monthly fee of $13 and then an additional 6 cents per minute of use. In Plan B, there is no monthly fee, but the customer pays 8 cents per minute of

  3. C++

    // Program: name of program // Author: your name // Date Written: date you began writing the program /* Abstract: Brief description of the program */ Include in-line comments in the body of your program. You can convert

  4. Algebra

    A phone company has a monthly data plan where a customer pays flat monthly fee of $20 and then a certain amount of money per gigabyte (GB) of data used on the phone. If a customer uses 3 GB, the monthly cost will be $26. If the

  1. java programming

    write a java program using arrays function for hotel bill calculation?

  2. Pseudocode

    Write an algorithm and pseudocode for A salesperson wants to write a program to calculate their gross monthly pay based on their annual salary, total sales, and commission rate. The program's output is the monthly pay calculated

  3. Algebra

    A phone company offers two monthly charge plans. In Plan A, the customer pays a monthly fee of $35.70 and then an additional 6 cents per minute of use. In Plan B, the customer pays a monthly fee of $30 and then an additional 7

  4. Math - APPRICIATE ALL HELP!

    Suppose that a household's monthly water bill (in dollars) is a linear function of the amount of water the household uses (in hundreds of cubic feet, HCF). When graphed, the function gives a line with a slope of 1.75. If the

  1. java

    Write a java application that finds the smallest of several integers. Prompt the user for the number of integers that will be input, then prompt the user for that number of integers. Evaluate the integers to determine the smallest

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

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

  4. 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:

You can view more similar questions or ask a new question.