use java 8 pls 25m left ALL O 2 2. Rest API: Country Codes Given a country
Fantastic news! We've Found the answer you've been seeking!
Question:
use java 8 pls
Transcribed Image Text:
25m left ALL O 2 2. Rest API: Country Codes Given a country name and a phone number, query an API to get calling codes for the country. Prepend the calling code to the phone number and return the string. If the data array is empty. return -1. If there are multiple calling codes returned, use the one at the highest index. The format of the number should be: + Example: +1 765355443 Given a country name, fetched the information from the API at https://jsonmock.hackerrank.com/api/countrie s?name= Each country in data has the following schema: ● name - The name of the country (String) • capital. The name of the capital city for the country (String) • callingCodes. An array of all the calling codes for the country (String Array) • The country schema may contain other fields which are not relevant for this question. An example of a country record is as follows: name : Afghanistan , nativeName : , topLevelDomain : [ .af ], alpha2Code : AF , numericCode : 004 , alpha3Code : AFG , currencies : [ AFN ], callingCodes : [ } 93 ], capital : Kabul . If a country is in the system, the returned data array contains exactly 1 result. Otherwise, the data array is empty. ******* m left ALL Function Description Complete the getPhoneNumbers function in the editor below. getPhoneNumbers has the following parameters: string country: the country to query string phoneNumber: the phone number Returns string: the completed phone number or -1 Constraints ● The country name may contain uppercase and lowercase English letters and (ascii 32) Input Format For Custom Testing ▾ Sample Case 9 Sample Input For Custom Testing Afghanistan 656445445 Sample Output +93 656445445 Explanation A call is made to API https://jsonmock.hackerrank.com/api/countrie s?name Afghanistan. The calling codes array contains 1 entry, 93 . ▸ Sample Case 1 ▸ Sample Case 2 contains 1 entry, 93 . ▾ Sample Case 1 Sample Input For Custom Testing Puerto Rico 564593986 Sample Output +1939 564593986 Explanation A call is made to the API to fetch the record for Puerto Rico. The returned callingCodes = [ 1787 , 1939]. Use the higher index code, callingCodes[1]. Sample Case 2 Sample Input For Custom Testing Oceania 987574876 Sample Output -1 Explanation The API call return has an empty data array. 13 14 15 class Result 16 17 V /* 18 PANNENHUNDE 19 20 *The function is expected to return a STRING. * The function accepts following parameters: * 1. STRING country * 2. STRING * API URL: https://jsonmock.hackerrank.com/api/countries?name= */ 27 V public static String getPhoneNumbers (String country, String phoneNumber) { 21 22 23 24 25 26 28 29 30 * Complete the getPhoneNumbers function below. * } 31 32 33 y nih? phoneNumber 25m left ALL O 2 2. Rest API: Country Codes Given a country name and a phone number, query an API to get calling codes for the country. Prepend the calling code to the phone number and return the string. If the data array is empty. return -1. If there are multiple calling codes returned, use the one at the highest index. The format of the number should be: + Example: +1 765355443 Given a country name, fetched the information from the API at https://jsonmock.hackerrank.com/api/countrie s?name= Each country in data has the following schema: ● name - The name of the country (String) • capital. The name of the capital city for the country (String) • callingCodes. An array of all the calling codes for the country (String Array) • The country schema may contain other fields which are not relevant for this question. An example of a country record is as follows: name : Afghanistan , nativeName : , topLevelDomain : [ .af ], alpha2Code : AF , numericCode : 004 , alpha3Code : AFG , currencies : [ AFN ], callingCodes : [ } 93 ], capital : Kabul . If a country is in the system, the returned data array contains exactly 1 result. Otherwise, the data array is empty. ******* m left ALL Function Description Complete the getPhoneNumbers function in the editor below. getPhoneNumbers has the following parameters: string country: the country to query string phoneNumber: the phone number Returns string: the completed phone number or -1 Constraints ● The country name may contain uppercase and lowercase English letters and (ascii 32) Input Format For Custom Testing ▾ Sample Case 9 Sample Input For Custom Testing Afghanistan 656445445 Sample Output +93 656445445 Explanation A call is made to API https://jsonmock.hackerrank.com/api/countrie s?name Afghanistan. The calling codes array contains 1 entry, 93 . ▸ Sample Case 1 ▸ Sample Case 2 contains 1 entry, 93 . ▾ Sample Case 1 Sample Input For Custom Testing Puerto Rico 564593986 Sample Output +1939 564593986 Explanation A call is made to the API to fetch the record for Puerto Rico. The returned callingCodes = [ 1787 , 1939]. Use the higher index code, callingCodes[1]. Sample Case 2 Sample Input For Custom Testing Oceania 987574876 Sample Output -1 Explanation The API call return has an empty data array. 13 14 15 class Result 16 17 V /* 18 PANNENHUNDE 19 20 *The function is expected to return a STRING. * The function accepts following parameters: * 1. STRING country * 2. STRING * API URL: https://jsonmock.hackerrank.com/api/countries?name= */ 27 V public static String getPhoneNumbers (String country, String phoneNumber) { 21 22 23 24 25 26 28 29 30 * Complete the getPhoneNumbers function below. * } 31 32 33 y nih? phoneNumber
Expert Answer:
Answer rating: 100% (QA)
To solve this problem we need to follow these steps 1 Make a GET request to the API endpoint ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these electrical engineering questions
-
PLS In the Loan Calculator worksheet, the formula in cell D8 should calculate the total cost of the loan. 109 2/3 27. Bao wants t atas Table Get External Data Refresh All Stocks Geogra... L Sort...
-
Java Company earned net income of $85,000 during the year ended December 31, 2018. On December 15, Java declared the annual cash dividend on its 4% preferred stock (par value, $120,000) and a $0.25...
-
Java Hut leased a specialty expresso machine for a 10-year non-cancelable term. At the end of the 10-year term, Java Hut has four consecutive one-year renewal options. A replacement machine can be...
-
A managers key task is to balance which four customer service factors against which six logistics cost factors?
-
What are the two sampling risks associated with variables sampling? What types of losses are associated with each of these risks?
-
Compound A, C8H10O, has the IR and 1H NMR spectra shown. Propose a structure consistent with the observed spectra, and assign each peak in the NMR spectrum. Note that the absorption at 5.5 ?...
-
The IRR of this investment is located at which point? a. A b. C c. D d. E
-
Wyco Company manufactures toasters. For the first 8 months of 2011, the company reported the following operating results while operating at 75% of plant capacity. Sales (400,000 units) ......
-
Assume the company is transitioning from a traditional file environment to a database management system / relational database. - Describe and explain the challenges / issues in transitioning from a...
-
A special case of a normal family is one in which the mean and the variance are related, the n(, ) family. If we are interested in testing this relationship, regardless of the value of , we are again...
-
Use your knowledge of cost functions to calculate the missed cost data in the accompanying table. Round your answers to two digits after the decimal. Quantity Marginal cost Fixed cost Variable cost...
-
How can acting unprofessionally in a business social situation (for example the annual company picnic or holiday party) hurt your career? Share some examples of inappropriate behavior at business...
-
What would be the appropriate adjusting journal entries: The notes payable balance relates to a bank loan obtained in 2018 that is payable in full on august 31,2023. the loan agreement specifies that...
-
1:Explain your understanding of why it is important to be persuasive in negotiation and how you would go about being persuasive in a negotiation. 2: Research a conflict or dispute that has occurred...
-
What is going on with your site? I have searched for examples for the following papers and could not find any info on them. They are: 1. Create Visual Communication 2. Comm Regulation and Policy 3....
-
One of your staff members has been asked to give two speeches. Details are as follows: first speech - large target audience; objective: to inform them of company progress over the past year; and ...
-
A foundation of 3 mx2.5 m is to be constructed within the property line. An eccentricity is needed to be performed in the length direction and equal to 30 cm. The load is 10 degrees inclined from the...
-
What does non-recourse financing mean?
-
Leslie and Leon Lazo are married and file a joint return for 2012. Leslie's Social Security number is 466-47-3311 and Leon's is 467-74-4451. They live at 143 Snapdragon Drive, Reno, NV 82102. For...
-
Joan is a self-employed attorney in New York City. Joan took a trip to San Diego, CA, primarily for business, to consult with a client and take a short vacation. On the trip, Joan incurred the...
-
Dr. George E. Beeper is a single taxpayer. He lives at 45 Mountain View Dr., Apt. 321, Spokane, WA 99210. Dr. Beeper's Social Security number is 775-88-9531. Dr. Beeper works for the Pine Medical...
-
Enter the following transactions of an antiques shop in the accounts and extract a trial balance as at 31 March 2017. 2017 March 1 Started in business with 8,000 in the bank. 2 Bought goods on time...
-
Record the following transactions for the month of January of a small finishing retailer, balance-off all the accounts, and then extract a trial balance as at 31 January 2016. 2016 Jan 1 Started in...
-
On 1 October 2016, the owner of the USS Enterprise, Mr Kirk, decides that he will boldly go and keep his records on a double entry system. His assets and liabilities at that date were: Kirk's...
Study smarter with the SolutionInn App