Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, can you check my error? please Question: Internet Service Provider An Internet service provider has three different subscription packages for its customers: Package A:

Hello, can you check my error? please

Question: Internet Service Provider

An Internet service provider has three different subscription packages for its customers:

Package A: $9.95 per month for 10 hours access. Additional hours are $2.00 per hour

Package B: $13.95 per month for 20 hours access. Additional hours are $1.00 per hour

Package C: $29.99 per month for unlimited access.

Write a program that performs the following two tasks:

ask the user to enter the letter of the package the customer purchased (A, or B, or C) and the number of hours that we used. The program then should calculate and display the total charges for the package.

if the customer purchased Package A, the program should also calculate and display the amount of money the customer would save by switching to package B or C

If the customer purchased Package B, the program should also calculate and display the amount of money the customer would save by switching to Package C.

For task 2 & 3, If there would be no savings, no message should be displayed.

Requirements: turn in the .java file as attachment

Program:

1 //import the header package 2 import java.io.*; 3 import java.util.Scanner;//Needed for Scanner class 4 //creat InternetPackage 5 6 class internetPackage 7 { 8 //define the main(0 function 9 public static void main(String[] args) 10 { 11 //declare the variables 12 int hours; 13 char Package; 14 double total_amount=0; 15 String s1; 16 //Creat a scanner object for keyboard input 17 //To get the inputs from the user 18 Scanner keyboard= new Scanner(System.in); 19 //input the statements 20 //prompt the user to enter the package 21 System.out.println("\tMenu "); 22 System.out.println("\tA-Package A \tB-Package B"+" \tC-Package C'"); 23 System.out.println("Enter your choice:"); 24 s1=keyboard.nextLine(); 25 Package=s1.charAt(0); 26 //promt the user to enter the 27 //number of hours 28 System.out.println("Enter hours:"); 29 hours=keyboard.nextInt(); 30 //user switch case to select the package 31 switch(Package) 32 { 33 case 'A': 34 if(hours<10) 35 total_amount=9.95; 36 else 37 total_amount=9.95+((hours-10)*2); 38 break; 39 case 'B': 40 if (hours<20) 41 total_amount=13.95; 42 else 43 total_amount=13.95+((hours-20)*1); 44 break; 45 case 'C': 46 total_amount=19.95; 47 break; 48 { 49 int hours; 50 double packageA_amount, 51 packageB_amount,packageC_amount; 52 double total_amount=0; 53 DecimalFormat formatter= 54 new DecimalFormat("0.00"); 55 //Creat a scanner object for keyboard input 56 //To get the inputs from the user 57 Scanner keyboard= new Scanner(System.in); 58 59 //inputting hours 60 System.out.println("Enter hours:"); 61 hours=keyboard.nextInt(); 62 63 //condition Package A 64 if(hours<10) 65 packageA_amount=9.95; 66 else 67 packageA_amount=9.95+((hours-10)*2); 68 //condition for package B 69 if(hours<20) 70 packageB_amount=14.95; 71 else 72 packageB_amount=14.95+(hours-20)*1; 73 74 packageB_amount=19.95; 75 //outputting data 76 double difference; 77 78 //display the total amount of 79 //monthly bill on package 80 System.out.println("Monthly bill on" + "Package is:$" + total_amount); 81 System.exit(0); 82 } 83 }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Real Time Database Systems Architecture And Techniques

Authors: Kam-Yiu Lam ,Tei-Wei Kuo

1st Edition

1475784023, 978-1475784022

More Books

Students also viewed these Databases questions

Question

Discuss what would be covered in a first interview with an athlete.

Answered: 1 week ago

Question

understand the key issues concerning international assignments

Answered: 1 week ago