Your monthly phone bill has just arrived, and it's unexpectedly large. You decide to verify the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Your monthly phone bill has just arrived, and it's unexpectedly large. You decide to verify the amount by recalculating the bill based on your phone call logs and the phone company's charges. The logs are given as a string S consisting of N lines separated by end-of-line characters (ASCII code 10). Each line describes one phone call using the following format: "hh:mm:ss, nnn-nnn-nnn", where "hh:mm:ss" denotes the duration of the call (in "hh" hours, "mm" minutes and "ss" seconds) and "nnn-nnn-nnn" denotes the 9-digit phone number of the recipient (with no leading zeros). Each call is billed separately. The billing rules are as follows: • If the call was shorter than 5 minutes, then you pay 3 cents for every started second of the call (e.g. for duration "00:01:07" you pay 67 * 3 = 201 cents). • If the call was at least 5 minutes long, then you pay 150 cents for every started minute of the call (e.g. for duration "00:05:00" you pay 5* 150 = 750 cents and for duration "00:05:01" you pay 6 * 150 = 900 cents). • All calls to the phone number that has the longest total duration of calls are free. In the case of a tie, if more than one phone number shares the longest total duration, the promotion is applied only to the phone number whose numerical value is the smallest among these phone numbers. Write a function: class Solution { public int solution (String S); } that, given a string S describing phone call logs, returns the amount of money you have to pay in cents. For example, given string S with N = 3 lines: "00:01:07,400-234-090 00:05:01,701-080-080 00:05:00,400-234-090" the function should return 900 (the total duration for number 400-234-090 is 6 minutes 7 seconds, and the total duration for number 701-080-080 is 5 minutes 1 second; therefore, the free promotion applies to the former phone number). Assume that: • N is an integer within the range [1..100]; • every phone number follows the format "nnn- nnn-nnn" strictly; there are no leading zeros; • the duration of every call follows the format "hh:mm:ss" strictly (00 ≤ hh ≤ 99, 00 ≤ mm, ss ≤ 59); • each line follows the format "hh:mm:ss, nnn- nnn-nnn" strictly; there are no empty lines and spaces. In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment. Your monthly phone bill has just arrived, and it's unexpectedly large. You decide to verify the amount by recalculating the bill based on your phone call logs and the phone company's charges. The logs are given as a string S consisting of N lines separated by end-of-line characters (ASCII code 10). Each line describes one phone call using the following format: "hh:mm:ss, nnn-nnn-nnn", where "hh:mm:ss" denotes the duration of the call (in "hh" hours, "mm" minutes and "ss" seconds) and "nnn-nnn-nnn" denotes the 9-digit phone number of the recipient (with no leading zeros). Each call is billed separately. The billing rules are as follows: • If the call was shorter than 5 minutes, then you pay 3 cents for every started second of the call (e.g. for duration "00:01:07" you pay 67 * 3 = 201 cents). • If the call was at least 5 minutes long, then you pay 150 cents for every started minute of the call (e.g. for duration "00:05:00" you pay 5* 150 = 750 cents and for duration "00:05:01" you pay 6 * 150 = 900 cents). • All calls to the phone number that has the longest total duration of calls are free. In the case of a tie, if more than one phone number shares the longest total duration, the promotion is applied only to the phone number whose numerical value is the smallest among these phone numbers. Write a function: class Solution { public int solution (String S); } that, given a string S describing phone call logs, returns the amount of money you have to pay in cents. For example, given string S with N = 3 lines: "00:01:07,400-234-090 00:05:01,701-080-080 00:05:00,400-234-090" the function should return 900 (the total duration for number 400-234-090 is 6 minutes 7 seconds, and the total duration for number 701-080-080 is 5 minutes 1 second; therefore, the free promotion applies to the former phone number). Assume that: • N is an integer within the range [1..100]; • every phone number follows the format "nnn- nnn-nnn" strictly; there are no leading zeros; • the duration of every call follows the format "hh:mm:ss" strictly (00 ≤ hh ≤ 99, 00 ≤ mm, ss ≤ 59); • each line follows the format "hh:mm:ss, nnn- nnn-nnn" strictly; there are no empty lines and spaces. In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.
Expert Answer:
Answer rating: 100% (QA)
JAVA Program to check the telephone bill import javautil ... View the full answer
Related Book For
Financial Algebra advanced algebra with financial applications
ISBN: 978-0538449670
1st edition
Authors: Robert K. Gerver
Posted Date:
Students also viewed these programming questions
-
The average monthly cell phone bill was reported to be $50.07 by the U.S. Wireless Industry. Random sampling of a large cell phone company found the following monthly cell phone charges: At the 0.05...
-
Phone companies itemize charges on monthly bills. There are several fees, call surcharges, and taxes. There could be charges for maintenance of the phone wiring within the home. These charges inflate...
-
A cell phone company charges $0.12 for connecting a call plus $0.08 per minute or any part thereof (e.g., a phone call lasting 2 minutes and 5 seconds costs $0.12 + 3 $0.08). Sketch a graph of the...
-
Five separate projects have calculated rates of return of 8, 11, 12.4, 14, and 19% per year. An engineer wants to know which projects to accept on the basis of rate of return. She learns from the...
-
Discuss how the salesperson is a critical link between the company and the customer.
-
How does the existence of asymmetric information lead to market inefficiencies?
-
If you were trying to examine this issue, how would you proceed? Any suggestions for me to take next steps? same. Is that what happened? You normally wouldnt borrow money from the company, would you?
-
Echo Canyon Muffins sells its muffins to restaurants and coffee houses for an average selling price of $ 27 per case. The following information relates to the budget for Echo Canyon Muffins for this...
-
On a private flight with capacity for 150 people, $800,000 per person is charged, plus $25,000 for each unsold seat on the plane. How many people must travel on the plane and what will be the price...
-
The trial balance of Pacilio Security Services Inc. as of January 1, 2020, had the following normal balances: Cash ..................$122,475 Petty cash ................ 100 Accounts receivable...
-
The WBS is used to create the project schedule based on the activities needed to complete the work of the project. Based on the selected project of interest consolidation of office a WBS. Among other...
-
what is lowe's market segmentation ?
-
Why should it study the link between health/biology and psychology?
-
Please evaluate the impact of Gestalt Psychology to the American Psychology scene.?
-
'In psychology, studying personal experience should be more important than measuring traits and abilities.' Critically evaluate this statement, drawing on evidence from social psychology and the...
-
William James is the father of American Psychology. His Functionalist view was different than the psychology that was emerging in Europe at the same time. Discuss functionalism and describe how...
-
Here is the demographic pyramid for South Korea. The pyramid illustrates the size of the different age cohorts in a country. The typical shape is, precisely, that of a pyramid. As you can see, in the...
-
Which task is performed by a book-keeper? A. Analysing the trading results B. Entering transactions in the ledger C. Preparing year-end financial statements D. Providing information for...
-
Mountaineer Products Incorporated manufactures mountain-bike accessories. It is considering making a new type of reflector for night biking. The expense and revenue functions are E = -450p + 90,000...
-
Four people invested in a restaurant. One person invested $100,000. Two others invested in the ratio x:2x, and the fourth person invested an amount equal to the other three investors combined. The...
-
Find the mean, median, mode, and range for each data set given. a. 7, 12, 1, 7, 6, 5, 11 b. 85, 105, 95, 90, 115 c. 10, 14, 16, 16, 8, 9, 11, 12, 3 d. 10, 8, 7, 5, 9, 10, 7 e. 45, 50, 40, 35, 75 f....
-
Stadler Corporations federal income tax rate is 34 percent. It reports $100,000 depreciation expense on its financial statements and deducts $140,000 depreciation expense on its tax return. How...
-
Which of the following items is not deductible? a. Dues for club used solely for business meetings b. Directly related business entertainment c. Business gift of less than $25 in value d. Dues for...
-
John is a teacher at a local high school. During 2017, he travels three days per week to a school in the next county to work with gifted children in an after-school program that does not end until...
Study smarter with the SolutionInn App