Question

In: Computer Science

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 many hours were used. Determine max hours. Months with 30 days have 720 hours, and months with 31 days have 744 hours. February, with 28 days, has 672 hours. Month Days Hours January 31 744 February 28 672 March 31 744 April 30 720 May 31 744 June 30 720 July 31 744 August 31 744 September 30 720 October 31 744 November 30 720 December 31 744 Input validation: Be sure the user only selects package A, B, or C. Also, the number of hours used in a month cannot exceed maxHours (or be less than 0). Display the charge for the Package chosen. Display how much money Package A customers would save if they purchased packages B or C; how much money Package B customers would save if they purchased packages A or C; and how many packages C customers would save if they purchased packages A or B. If there would be no savings, no message should be printed. What to hand in: Please see the title page for requirements for assignments. You need the following in a single Word document: • Source code listing fully documented (comments for purpose, file, programmer, all variable declarations, and major tasks). • Test runs to show valid and invalid data as well as savings. • User Guide with Purpose stated for a User, a simple run to illustrate the capability of the program and a section for assumptions and limitations • A hierarchy chart for example to calculate the area of a rectangle

Solutions

Expert Solution

An Internet service provider has three different subscription packages
* for its customers.
*
*        Package A:   For $9.95 per month 10 hours of access 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 hours.
*
*        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.
*/
import java.util.Scanner;


public class InternetServiceProvider {
   public static void main (String args[])
   {
       while (true)
       {
           printMonthlyBill(calculateBill(getHours(), menu()));
       }
   }
  
   public static double getHours()
   {
       double hours;
      
       Scanner inputHours = new Scanner (System.in);
      
       System.out.print("Please enter the hours used: ");
       hours = inputHours.nextDouble();
      
       inputHours.close();
      
       return hours;
   }
  
   public static int menu ()
   {
       int packageChoice;
      
       Scanner userInput = new Scanner (System.in);
      
       System.out.println("[1] Package A");
       System.out.println("[2] Package B");
       System.out.println("[3] Package C");
       System.out.print("Please select your package: ");
       packageChoice = userInput.nextInt();
       userInput.close();
      
       return packageChoice;
   }
  
   public static double calculateBill(double hours, int packageChoice)
   {
       switch (packageChoice)
       {
           case 1:
               if (hours < 10)
               {
                   return 9.95;
               }
              
               else
               {
                   return (hours - 10)*2 + 9.95;
               }
              
           case 2:
               if (hours < 20)
               {
                   return 13.95;
               }
              
               else
               {
                   return (hours - 20) + 13.95;
               }          
           case 3:
               return 19.95;
              
           default:
               System.out.println("Invalid input!");
               return 0;
       }
   }
  
   public static void printMonthlyBill(double bill)
   {  
       System.out.println("Your monthy bill is $" + bill);
   }
}


Related Solutions

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...
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....
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...
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...
**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...
Assume you are a senior manager of a cell phone provider such as TELUS, Rogers or...
Assume you are a senior manager of a cell phone provider such as TELUS, Rogers or Bell. How might your (cell phone provider) costs of production be affected in the short-run and long-run? (approx. 230 words)
The quality control manager of a major cell phone provider is concerned about the life of...
The quality control manager of a major cell phone provider is concerned about the life of the cell phone batteries they use. He took a sample of 13 batteries from a recent shipment and used them continuously until they failed to work. The manager measured the number of hours the batteries lasted and found the mean to be 550.4 with a standard deviation of 315.3. What is the critical value for α = .10 to test the claim that the...
4) You are hired by a cell phone provider to determine the number of times per...
4) You are hired by a cell phone provider to determine the number of times per day their customers interact with their smartphone. You take a random sample of 25 customers and find the average number of interactions to be 75 times per day with a sample standard deviation of 5. 4 a. If you decide to construct a confidence interval for the population mean number of interactions, what distribution would you use and why? ________________________________________________________________________________ ________________________________________________________________________________ ________________________________________________________________________________ b. Construct...
4) You are hired by a cell phone provider to determine the number of times per...
4) You are hired by a cell phone provider to determine the number of times per day their customers interact with their smartphone. You take a random sample of 25 customers and find the average number of interactions to be 75 times per day with a sample standard deviation of 5. 4 a. If you decide to construct a confidence interval for the population mean number of interactions, what distribution would you use and why? ________________________________________________________________________________ ________________________________________________________________________________ ________________________________________________________________________________ b. Construct...
A friend or yours is considering two cell phone service providers. Provider A charges $100 per...
A friend of yours is considering two cell phone service providers. Provider A charges $100 per month for the service regardless of the number of phone calls made. Provider B does not have a fixed service ree but instead charges $1 per minute for calls. Your friend's monthly demand for minutes or calling is given by the equation p-120-30P, where P is the price of a minute.  With Provider A, the cost of an extra minute is 5 _______ .with...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT