Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 3 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 27 Aug 2017 My Price 12.00

parenthesis format

Problem 2

Write a PhoneNumber class that gets initialized with a 10-digit phone number. In the call PhoneNumber.new(ph), the input phtake any of these possible formats:

 

• a 10-digit integer

 

• a string of 10 digits

 

• (ddd) ddd-dddd where d is any digit [parenthesis format]

 

• ddd-ddd-dddd where d is any digit [hyphen format]

 

Wherever whitespace appears in a string format, we can have a string of zero or more whitespace characters (including before and after the string as a whole). A PhoneNumber object responds to the to_s message which returns the number as a string in parenthesis format, and the area_code, prefix, and root messages which return the parts of the number in string format, as illustrated

 

here:

 

a = PhoneNumber.new(1234567890)

 

puts a # (123) 456-7890 puts a.area_code # 123 puts a.prefix # 456

 

puts a.root # 7890

 

puts PhoneNumber.new(' 7778889999 ') # (777) 888-9999 puts PhoneNumber.new(' (555)444-3333') # (555) 444-3333

 

PhoneNumber.new('1234')

 

# ArgumentError: Improper phone number syntax

 

PhoneNumber.new('(12) 333-4444')

 

# ArgumentError: Improper phone number syntax

 

PhoneNumber.new('123- 456- 7890')

# ArgumentError: Improper phone number syntax

Answers

(5)
Status NEW Posted 27 Aug 2017 09:08 AM My Price 12.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)