id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

zbaharav@kehillah.org twelvedaysofap > makePhoneNumber
prev  |  next  |  chance

Given an input string representing 10-digits phone number, determine if the number is valid, and return the number formatted. A number is valid if neither the area-code nor the actual number starts with zero. If the number is invalid, return an empty string. The formatting should be in the form (xxx)xxx-xxx , where x represents the digits.


makePhoneNumber("6502345678") → "(650)234-5678"
makePhoneNumber("0502345678") → ""
makePhoneNumber("1500345678") → ""

...Save, Compile, Run (ctrl-enter)

public String makePhoneNumber(String inNumber){ }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 100

Copyright Nick Parlante 2017 - privacy