Question: How to correct my code? Homework: Reformat a Phone Number Let's get some practice working with Java Strings: an incredibly useful data type for working

How to correct my code?  How to correct my code? Homework: Reformat a Phone Number Let's
get some practice working with Java Strings: an incredibly useful data type

Homework: Reformat a Phone Number Let's get some practice working with Java Strings: an incredibly useful data type for working with text. Write a function called reformatPhoneNumber. It should take a String containing a phone number in the format 111-222-3333 and return it reformatted as (111) 222- 3333. 2 3 1 String reformatPhone Number (String reformatPhone Number) { String a = reformatPhone Number.substring(0, 2); String b = reformatPhoneNumber .substring(4, 11); String c = a + b; return c; 6) 4 5 Ran 3 tests. Stopped after finding 1 failure. Here is one: Testing reformatPhone Number (String reformatPhone Number = "123-456-7890") failed: Solution returned: "(123) 456-7890" Submission returned: "12456-789

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!