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...
-
Do you think Apple's success was entirely dependent upon Steve Jobs' role as head of the hierarchy? What are the potential liabilities of a company's being so strongly connected to the decision...
-
The accounting records of Connor Electronics show the following data. Beginning inventory ........ 3,000 units at $5 Purchases .............. 8,000 units at $7 Sales ............... 9,400 units at...
-
The L-shaped frame is made from two segments, each of length \(L\) and flexural stiffness \(E I\). Determine the horizontal displacement of point \(C\). W C L A B- -L-
-
Presented below are selected transactions at Ridge Company for 2017. Jan. 1 Retired a piece of machinery that was purchased on January 1, 2007. The machine cost $ 62,000 on that date. It had a useful...
-
design a finite-state automaton to accept the language defined by the regular expression in the referenced exercise 0 So 1 $1 0, 1
-
The following data relate to the operations of Shilow Company, a wholesale distributor of consumer goods: Current assets as of March 31: Cash $ 8,000 Accounts receivable 20,000 Inventory 36,000...
-
S Ltd runs a business that sells mining equipment and related products to customers. On 31 March 2022, A Ltd sent the following order to S Ltd: 5 Granby cars (type XX) 1 Locomotive 12 Turnouts $ 159...
-
In order to correctly assess property taxes in the state, New Jersey has decided to require that all municipalities report the average home price in their districts. From past years, one municipality...
-
An advertising executive is interested in how viewers looked upon a television ad by McDonalds in New York City (either favorably or unfavorably). Briefly explain how the executive could analyze this...
-
Myers-Briggs Personality Types and Jungian Personality Types are two very popular descriptions of the material in this chapter. Using your search engine, access the Internet sites that refer to these...
-
Many salespeople, after being introduced to communication- style concepts, attempt to categorize each of their customers. They report that their relationships become mutually more enjoyable and...
-
Select several advertisements from a trade magazine. Analyze each one and determine which rational buying motives the advertiser is appealing to. Explain whether these advertisements also appeal to...
-
Identify the domain of the expression. x+5 2x+13x+15 The domain is all real numbers except - 22- The domain is all real numbers except -5 and -1/2- The domain is all real numbers except -5. The...
-
Prove that the mean heat capacities C P H and C P S are inherently positive, whether T > T 0 or T < T 0 . Explain why they are well defined for T = T 0 .
-
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.
-
Tests of controls: a. Are intended to detect material misstatements in financial statement accounts. b. Are concerned with how internal control policies or procedures are applied. c. Are evaluations...
-
Analytical procedures: a. Are intended to detect material misstatements in financial statement accounts. b. Are concerned with how internal control policies or procedures are applied. c. Are...
-
Substantive tests of details: a. Are intended to detect material misstatements in financial statement accounts. b. Are concerned with how internal control policies or procedures are applied. c. Are...
Study smarter with the SolutionInn App