An Internet Service Provider has three different subscriptionpackages for its cu
ID: 3616889 • Letter: A
Question
An Internet Service Provider has three different subscriptionpackages for its customers:Package A: For $9.95 per month 10 hours of access areprovided. Additional hours are $2.00 per hour.
Package B: For $14.95 per month 20 hours of access areprovided. Additional hours are $1.00 per hour.
Package C: For $19.95 per month unlimited access isprovided
Design a class that calculated a customer's monthly bill. It should store the letter of the package the customer haspurchased (A,B, or C) and the number of hours that were used. It should have a method that return the total charges. Demonstrate the class in a program that asks the user toselect a package and enter the number of hours used. Theprogram should display the total charges.
Package A: For $9.95 per month 10 hours of access areprovided. Additional hours are $2.00 per hour.
Package B: For $14.95 per month 20 hours of access areprovided. Additional hours are $1.00 per hour.
Package C: For $19.95 per month unlimited access isprovided
Design a class that calculated a customer's monthly bill. It should store the letter of the package the customer haspurchased (A,B, or C) and the number of hours that were used. It should have a method that return the total charges. Demonstrate the class in a program that asks the user toselect a package and enter the number of hours used. Theprogram should display the total charges.
Explanation / Answer
please rate - thanks import java.util.Scanner; public class IspDriver { public static void main(String[] args) {Scanner in = new Scanner (System.in); char choice; String c; double h; System.out.println("Enter the package: "); do{ System.out.println("A .PackageA B. Package B C. Package C"); c=in.next(); choice=c.charAt(0); if(choice'C') System.out.println("Invalid choice"); }while(choice'C'); System.out.println("Enter hours used: "); h=in.nextDouble(); ISP isp = new ISP(choice,h); System.out.printf("Your bill is is$%.2f ",isp.getBill()); } } ----------------------------------------------------- class ISP {private char pack; private double hours; public ISP() {pack='A'; hours=0;} public ISP(char p, double h) {pack=p; hours=h; } public void setpackage(char p) {pack=p; } public char getpackage() {return pack; } public void sethour(double h) {hours=h; } public double gethour() {return hours; } public double getBill() {double bill,h; if(pack=='A') { h=hours-10; bill=9.95+(2*(int)(h+.5)); //round hours up } else if(pack=='B') { h=hours-20; bill=14.95+(int)(h+.5); //round hours up } else bill=19.95; //roundhours up return bill; } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.