Write a Java program that calculates and prints the bill for a cellular telephone company. The...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Java program that calculates and prints the bill for a cellular telephone company. The company uses the following plans: (a) Premium Service: $25 plus (1) For day minutes (6:00 AM to 6:00 PM), the first 75 minutes are free; charges for over 75 minutes are $0.10 per minutes. (2) For night minutes (6:00 PM to 6:00 AM), the first 100 minutes are free; charges over 100 minutes are $0.05 per minute. (b) Regular Service: $10.00 plus first 50 minutes are free; charges over 50 minutes are $0.20 per minute. Input The input for the program must be the following: • Account Number Customer Name • • Service code (Premium or Regular) For Premium service: Number of Day minutes and Number of Night Minutes. Note that we are not asking the user the time when they made the call. You can use either the console or the JOptionPane to input the data. Frequently Asked Questions 1. How do you input a name that has multiple words like Mary Smith? You can use the method nextLine(). nextLine input a line of input for example the code: String name = console.nextLine(); will input a multiple words input. 2. What should the program output? Your program should output the customer name, account number, followed by the plan, minutes used, and bill total. See the sample run at the end of this document. 3. How do you check the service code? • The user may enter any string. • Your code should only accept the strings Premium or Regular and reject any other string as error. • The use may enter the code lowercase, uppercase or mixed. The following codes are all valid: premium, PRemium, REGular, regulAR. • The following strings are all invalid: Premum, reguler, Prem, reg, 123, help 4. What do you do if the user input Premium or Regular with lowercase letters or mixed letters (For example, premium, regular, or Regular)? • Use equalsignoreCase() method instead of equals method or • compareTolgnoreCase() method instead of compare To 5. What logic should the skeleton on my program follow? You can use an if statement: if (service code is premium){ do all the calculation for premium service in this block } else if(service code is regular){ do all the calculation for regular service in this block } else { the service code must be error; user entered other than regular or premium } Instead of an if statement as shown above, you can also use a switch statement. Here is the skeleton for a switch statement: switch (service code){ case: "REGULAR" : all code for regular goes here; break; case: "PREMIUM": all code for premium goes here; break; default: must be error. } Note: The switch statement requires you to upper case the service code. You can do that using the method toUpperCase(). Here is an example: String upCaseServiceCode = serviceCode.toUpperCase(); The statement takes the service code stored in the variable serviceCode and changes it to upper case and stores the result in the variable upCaseServiceCode. Sample Run Enter the account number: 1116 Enter the service type: regular or premium: PREMIUM Enter the daytime minutes used: 76 Enter the nighttime minutes used: 101 Account Number: 1116. Service Type: Premium Minutes Service Used (Day): 76 Minutes Service Used (Night): 101 Amount Due: $25.15 Enter the account number: 1111 Enter the service type: regular or premium: Regular Enter the number of minutes service used: 51 Account Number: 1111 Service Type: Regular Minutes Service Used: 51 Amount Due: $10.20 Enter the account number: 1112 Enter the service type: regular or premium: PreMiuM Enter the daytime minutes used: 75 Enter the nighttime minutes used: 100 Account Number: 1112 Service Type: Premium Minutes Service Used (Day): 75 Minutes Service Used (Night): 100 Amount Due: $25.00 Enter the account number: 1113 Enter the service type: regular or premium: regular/premium Invalid Service Type. Enter the account number: 1115 Enter the service type: regular or premium: Help Invalid Service Type. Write a Java program that calculates and prints the bill for a cellular telephone company. The company uses the following plans: (a) Premium Service: $25 plus (1) For day minutes (6:00 AM to 6:00 PM), the first 75 minutes are free; charges for over 75 minutes are $0.10 per minutes. (2) For night minutes (6:00 PM to 6:00 AM), the first 100 minutes are free; charges over 100 minutes are $0.05 per minute. (b) Regular Service: $10.00 plus first 50 minutes are free; charges over 50 minutes are $0.20 per minute. Input The input for the program must be the following: • Account Number Customer Name • • Service code (Premium or Regular) For Premium service: Number of Day minutes and Number of Night Minutes. Note that we are not asking the user the time when they made the call. You can use either the console or the JOptionPane to input the data. Frequently Asked Questions 1. How do you input a name that has multiple words like Mary Smith? You can use the method nextLine(). nextLine input a line of input for example the code: String name = console.nextLine(); will input a multiple words input. 2. What should the program output? Your program should output the customer name, account number, followed by the plan, minutes used, and bill total. See the sample run at the end of this document. 3. How do you check the service code? • The user may enter any string. • Your code should only accept the strings Premium or Regular and reject any other string as error. • The use may enter the code lowercase, uppercase or mixed. The following codes are all valid: premium, PRemium, REGular, regulAR. • The following strings are all invalid: Premum, reguler, Prem, reg, 123, help 4. What do you do if the user input Premium or Regular with lowercase letters or mixed letters (For example, premium, regular, or Regular)? • Use equalsignoreCase() method instead of equals method or • compareTolgnoreCase() method instead of compare To 5. What logic should the skeleton on my program follow? You can use an if statement: if (service code is premium){ do all the calculation for premium service in this block } else if(service code is regular){ do all the calculation for regular service in this block } else { the service code must be error; user entered other than regular or premium } Instead of an if statement as shown above, you can also use a switch statement. Here is the skeleton for a switch statement: switch (service code){ case: "REGULAR" : all code for regular goes here; break; case: "PREMIUM": all code for premium goes here; break; default: must be error. } Note: The switch statement requires you to upper case the service code. You can do that using the method toUpperCase(). Here is an example: String upCaseServiceCode = serviceCode.toUpperCase(); The statement takes the service code stored in the variable serviceCode and changes it to upper case and stores the result in the variable upCaseServiceCode. Sample Run Enter the account number: 1116 Enter the service type: regular or premium: PREMIUM Enter the daytime minutes used: 76 Enter the nighttime minutes used: 101 Account Number: 1116. Service Type: Premium Minutes Service Used (Day): 76 Minutes Service Used (Night): 101 Amount Due: $25.15 Enter the account number: 1111 Enter the service type: regular or premium: Regular Enter the number of minutes service used: 51 Account Number: 1111 Service Type: Regular Minutes Service Used: 51 Amount Due: $10.20 Enter the account number: 1112 Enter the service type: regular or premium: PreMiuM Enter the daytime minutes used: 75 Enter the nighttime minutes used: 100 Account Number: 1112 Service Type: Premium Minutes Service Used (Day): 75 Minutes Service Used (Night): 100 Amount Due: $25.00 Enter the account number: 1113 Enter the service type: regular or premium: regular/premium Invalid Service Type. Enter the account number: 1115 Enter the service type: regular or premium: Help Invalid Service Type.
Expert Answer:
Answer rating: 100% (QA)
Java program that calculates and prints the bill for a cellular telephone company TelephoneCompanyja... View the full answer
Related Book For
Modern Advanced Accounting in Canada
ISBN: 978-1259087554
8th edition
Authors: Hilton Murray, Herauf Darrell
Posted Date:
Students also viewed these programming questions
-
What should be the STP (Segmentation, Targeting, Positioning) based on boat industry in Canada?
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
You have now been asked to work with a textile startup business that your firm has just taken on as a client. The business is particularly in need of support and guidance with budgeting and how it...
-
1. how transfer pricing can be used to minimize taxes in a multinational corporation. Include a short numerical illustration. 2. wHAT are the arguments for and against the international convergence...
-
Explain the need for an MNC to "be global and act local." How can a firm design its organization to enable this?
-
David Barnes and his fiancée Valerie Shah are visiting Hawaii. At the Hawaiian Cultural Center in Honolulu, they are told that 2 out of a group of 8 people will be randomly picked for a free...
-
Which preventive, detective, and/or corrective controls would best mitigate the following threats? a. An employees laptop was stolen at the airport. The laptop contained personally identifying...
-
Brynne Packaging is a large packaging company, offering its customers the highest standards in innovative packaging solutions and reliable service. About 25% of the employees at Brynne Packaging are...
-
! Required information Use the following information for the Exercises 8-10 below. (Algo) [The following information applies to the questions displayed below.] Hemming Company reported the following...
-
Stan Barker opened Quik-Stop Market on January 3, 2017. The business is subject to FICA taxes. At the end of the first quarter of 2017, Barker, as president of the company, must file Form 941,...
-
A company wants to group a collection of autographed photos by price ranges. Make a relative frequency distribution of the prices using the intervals $0-$9.99, $10-$19.99, $20- $29.99, $30-$39.99,...
-
You have received an inquiry from a prospective client, Lazy Sofa, Inc., concerning the accounting for investments. Betty Jason, owner of Lazy Sofa, is considering investing some of her companys idle...
-
Write a program that 1. Prompt user to enter a positive 2 digit integer x. 2. Prints the last digit of x first, then prints the second last digit of x. 3. Convert this number to print as foot and...
-
Noguchi Company manufactures cooling systems. Noguchi produces all the parts necessary for its product except for one electronic component, which is purchased from two local suppliers: Manzer Inc....
-
A popular unit of measure in the ancient world was the cubit ( approximately the distance between a person\'s elbow and the end of the middle finger, when outstretched ) . Assume an estimated length...
-
You are studying ethical theories. If the ethical theories were full-proof or shall we say, always resulted in an effective decision everyone could live with, ethical decision-making...
-
XYZ Sample Company has 100 employees in 2023. XYZ Sample Company qualifies to receive the credit of 5.4% of Employer's Annual Federal Unemployment (FUTA) taxable wages when it files Form 940. As...
-
What are the before image (BFIM) and after image (AFIM) of a data item? What is the difference between in-place updating and shadowing, with respect to their handling of BFIM and AFIM?
-
On January 1, Year 2, PAT Ltd. acquired 90% of SAT Inc. when SAT's retained earnings were $1,000,000. There was no acquisition differential. PAT accounts for its investment under the cost method. SAT...
-
Assume that all of the facts in Problem 3 remain unchanged except that Green paid $211,800 for 60% of the voting shares of Mansford. Required: (a) Prepare a consolidated balance sheet at January 1,...
-
Identify the financial statement ratios typically used to assess profitability, liquidity and solvency, respectively.
-
Public choice economists believe that the behavior of individuals in politics, as in the marketplace, will be influenced by _________.
-
In private markets, an individual _________ link indicates that the goods consumers get reflect what they are willing to pay for.
-
Even though actors in both the private and public sectors are _________, the _________ are different.
Study smarter with the SolutionInn App