Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Java on JGrasp. A mobile phone service provider has three different subscr

ID: 3670674 • Letter: U

Question

Using Java on JGrasp.

A mobile phone service provider has three different subscription packages for its customers:

Package A: For 39.99$ per month 450 minutes provided. Additional minutes are 0.45$ per minute.

Package B: For 59.99$ per month 900 minutes provided. Additional minutes are 0.40$ per minute.

Package C: For 69.99$ per month 450 minutes provided. Additional minutes are free.

Design a class that calculates a customers monthly bill. It should store the letter of the package the customer purchased(A,B,C) and the number of minutes that were used. It should have a method that returns the total charges. Demonstrate the class in a program that asks the user to select a package and enter the number of minutes used. The program should desplay the total charges. Please use a switch statement for the package type.

Explanation / Answer

import java.util.Scanner;

public class InternetSericeProvider {

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);

}

}

import java.util.Scanner;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote