Internet Service Provider An internet service provider has three different subsc
ID: 3792178 • Letter: I
Question
Internet Service ProviderAn 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.
The program should prompt the user to enter the package letter and the hours used.
It should then calculate the users monthly bill. Use java for the program 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.
The program should prompt the user to enter the package letter and the hours used.
It should then calculate the users monthly bill. Use java for the program 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.
The program should prompt the user to enter the package letter and the hours used.
It should then calculate the users monthly bill. Use java for the program
Explanation / Answer
program
import java.util.*;
public class InternetBill
{
public static void main(String args[])
{
double usage_charge;
int extra_hours=0,hours=0;
Scanner in=new Scanner(System.in);
System.out.print("Enter the Internet Package letter A or B or C ?.... ");
char p=in.next().charAt(0);
if(Character.isLowerCase(p))
p=Character.toUpperCase(p);
System.out.println();
if(p!='C'){
System.out.print("Enter the number of hours used: ");
hours=in.nextInt();
}
switch(p)
{
case 'A': if(hours > 10)
extra_hours=hours-10;
usage_charge= 9.95 + (extra_hours * 2.00);
System.out.println("Monthly Bill for Internet Usage: $ "+usage_charge);
break;
case 'B': if(hours > 20)
extra_hours=hours-20;
usage_charge= 13.95 + (extra_hours * 1.00);
System.out.println("Monthly Bill for Internet Usage: $ "+usage_charge);
break;
case 'C':System.out.println("Monthly Bill for Internet Usage: $ 19.95");
break;
default: System.out.println("Invalid package letter");
}
}
}
SAMPLE OUTPUT
Enter the Internet Package letter A or B or C ?.... b
Enter the number of hours used: 23
Monthly Bill for Internet Usage: $ 16.95
Enter the Internet Package letter A or B or C ?.... c
Monthly Bill for Internet Usage: $ 19.95
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.