Question

In: Computer Science

Internet Service provider Part 1 (Java Program) An Internet service provider has three different subscription packages...

Internet Service provider Part 1 (Java Program)

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 of access are provided. Additional hours are $1.00 per hour.

Package C: For $19.95 per month unlimited access is provided.

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

Part 2

Modify the program you wrote for Part 1 so it also calculates and displays the amount of money Package A customers would save if they purchased Package B or C, the amount of money Package B customers would save if they purchased Package A or Package C, and the amount of money Package C customers would save if they purchased Package A or Package B . If there would be no savings, no message should be printed.

Solutions

Expert Solution

Answer 1:

import java.util.Scanner;

public class MonthlyBillCalculator {
   public static void main(String[] args) {

       // scanner to read data from user
       Scanner sc = new Scanner(System.in);
       char Package;
       double hoursUsed;
       double monthlyBill = 0;
       // starting infinite loop to get valid inputs from user
       while (true) {

           // reading type of package from user
           System.out.print("Enter Package (A/B/C) :");
           Package = sc.next().charAt(0);
           // reading data from user
           System.out.print("Enter number of hours used :");
           hoursUsed = sc.nextDouble();
           // checking if inputs are valid than comes out of the loop
           if ((Package == 'A' || Package == 'B' || Package == 'C') && (hoursUsed >= 0 && hoursUsed <= 50)) {
               break;
           } else {
               System.out.println("\nInvalid Input\n\nEnter the details again\n--------------------");
           }
       }
       // starting to switch to calculate based user selected package
       switch (Package) {
       // if selected type is A
       case 'A':
           if (hoursUsed <= 10) {
               monthlyBill = 9.95;
           } else {
               monthlyBill = 9.95 + ((hoursUsed -10) * 2);
           }
           break;
       case 'B':
           if (hoursUsed <= 10) {
               monthlyBill = 13.95;
           } else {
               monthlyBill = 13.95 + ((hoursUsed - 20) * 1);
           }
           break;
       case 'C':
           monthlyBill = 19.95;
           break;
       }
       System.out.printf("\nMonthly bill = $%.2f\n", monthlyBill);
       // based on usage suggesting Package type for user
      
   }
}

Answer 2:

import java.util.Scanner;

public class MonthlyBillCalculator {
   public static void main(String[] args) {

       // scanner to read data from user
       Scanner sc = new Scanner(System.in);
       char Package;
       double hoursUsed;
       double monthlyBill = 0;
       // starting infinite loop to get valid inputs from user
       while (true) {

           // reading type of package from user
           System.out.print("Enter Package (A/B/C) :");
           Package = sc.next().charAt(0);
           // reading data from user
           System.out.print("Enter number of hours used :");
           hoursUsed = sc.nextDouble();
           // checking if inputs are valid than comes out of the loop
           if ((Package == 'A' || Package == 'B' || Package == 'C') && (hoursUsed >= 0 && hoursUsed <= 50)) {
               break;
           } else {
               System.out.println("\nInvalid Input\n\nEnter the details again\n--------------------");
           }
       }
       // starting to switch to calculate based user selected package
       switch (Package) {
       // if selected type is A
       case 'A':
           if (hoursUsed <= 10) {
               monthlyBill = 9.95;
           } else {
               monthlyBill = 9.95 + ((hoursUsed - 10) * 2);
           }
           System.out.printf("\nMonthly bill = $%.2f\n", monthlyBill);
           if (monthlyBill > 19.5) {
               System.out.println("If you take Package C than you could have saved " + (monthlyBill - 19.95));
           }
           else if (monthlyBill > 13.95) {
               System.out.println("If you take Package B than you could have saved " + (monthlyBill - 13.95));
           }
           break;
       case 'B':
           if (hoursUsed <= 10) {
               monthlyBill = 13.95;
           } else {
               monthlyBill = 13.95 + ((hoursUsed - 20) * 1);
           }
           System.out.printf("\nMonthly bill = $%.2f\n", monthlyBill);
           if (monthlyBill > 19.5) {
               System.out.println("If you take Package C than you could have saved " + (monthlyBill - 19.95));
           }
           break;
       case 'C':
           monthlyBill = 19.95;
           break;
       }
       System.out.printf("\nMonthly bill = $%.2f\n", monthlyBill);
       // based on usage suggesting Package type for user

   }
}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me


Related Solutions

Program Requirements: An Internet service provider has three different subscription packages for its customers: Package A:...
Program Requirements: An Internet service provider has three different subscription packages for its customers: Package A: For $15 per month with 50 hours of access provided. Additional hours are $2.00 per hour over 50 hours. Assume usage is recorded in one-hour increments, Package B: For $20 per month with 100 hours of access provided. Additional hours are $1.50 per hour over 100 hours. Package C: For $25 per month with 150 hours access is provided. Additional hours are $1.00 per...
wirte a program in java Part I     Internet Service Provider An Internet service provider has three...
wirte a program in java Part I     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 $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 access is provided. Write a program that calculates a customer’s monthly bill. It should ask...
An Internet service provider has three different subscription packages for its customers: Package A: $9.95 per...
An Internet service provider has three different subscription packages for its customers: Package A: $9.95 per month 10 hours of access are provided.   Additional hours are $2.00 per hour. Package B: $14.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour. Package C: $19.95 per month unlimited access is provided. Write a MATLAB script to calculates a customer’s monthly bill. It should ask which package the customer has purchased and how many hours were used....
A mobile phone service provider has three different subscription packages for its customers: Package A: For...
A mobile phone service provider has three different subscription packages for its customers: Package A: For $39.99 per month 450 minutes are provided. Additional minutes are $0.45 per minute. Package B: For $59.99 per month 900 minutes are provided. Additional minutes are $0.40 per minute. Package C: For $69.99 per month unlimited minutes provided. Write a program that calculates a customer’s monthly bill. It should ask which package the customer has purchased and how many minutes were used. It should...
CPSC 1103 Assignment 1 Problem A cell phone provider has three different subscription packages for its...
CPSC 1103 Assignment 1 Problem A cell phone 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 $14.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour. Package C: For $19.95 per unlimited access is provided. Write a program to ask which package the customer has purchased, what month they are using, and how...
**PYTHON** A new movie theatre has three different subscription packages for its customers: Package A: For...
**PYTHON** A new movie theatre has three different subscription packages for its customers: Package A: For $18.95 per month, the customer can watch 2 movies. Any additional movie requires an additional $2 per movie. Package B: For $22.95 per month, the customer can watch 4 movies. Any additional movie requires an additional $1 per movie. Package C: For $30.99 per month, the customer can watch an unlimited amount of movie. Write a script that calculates a customer’s monthly bill. It...
An internet service provider​ (ISP) has experienced rapid growth in the past five years. As part...
An internet service provider​ (ISP) has experienced rapid growth in the past five years. As part of its marketing​ strategy, the company promises fast connections and dependable service. To achieve its​ objectives, the company constantly evaluates the capacity of its servers. One component of its evaluating is an analysis of the average amount of time a customer is connected and actively using the Internet daily. A random sample of 12 customer records shows the following daily usage​ times, in minutes....
Internet service: An Internet service provider sampled 530 customers, and finds that 70 of them experienced...
Internet service: An Internet service provider sampled 530 customers, and finds that 70 of them experienced an interruption in high-speed service during the previous month. (b) Construct a 90% confidence interval for the proportion of all customers who experienced an interruption. Round the answers to at least three decimal places.
Internet service: An Internet service provider sampled 545 customers, and finds that 65 of them experienced...
Internet service: An Internet service provider sampled 545 customers, and finds that 65 of them experienced an interruption in high-speed service during the previous month. (b) Construct a 99.8% confidence interval for the proportion of all customers who experienced an interruption. Round the answers to at least three decimal places. A 99.8% confidence interval for the proportion of all customers who experienced an interruption is _<p<_.
A communications company offers 16 different television packages and 16 different internet packages. Of those, 5...
A communications company offers 16 different television packages and 16 different internet packages. Of those, 5 packages include both television and internet. How many ways are there to choose either television or internet, but not both?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT