1. Engineering
  2. Computer Science
  3. preparation be sure youve developed a bnf grammar that describes...

Question: preparation be sure youve developed a bnf grammar that describes...

Question details

PREPARATION Be sure youve developed a BNF grammar that describes the language of phone numbers according to the Practice BNF item. Lets call this the US phone number grammar One variation in how we write down US phone numbers is that we sometimes leave off the parentheses around the area code and instead use a dash after it: 757-555-0000 for example Many businesses have adopted the practice of using. (period) instead of (dash) between the number groups: 757.555.0000 for example By convention, intenational telephone numbers begin with a plus sign +) followed by a 1, 2, or 3-digit country code. The US country code is1. So the example US phone number would be written as 1757.555.0000 in this international style 1. (5 pts) Write down a BNF grammar for US phone numbers that use the dash after the area code instead of parentheses around it. 2. (5 pts) Write down a BNF grammar for US phone number written in the international style 3. (15 pts) Write a program that allows the user to input a character string from the keyboard, and tell the user if that string complies with the US phone number grammar (that is, the one from the Practice BNF item) Your program should output that string followed by YES if the string is acceptable, and NO ifit is not So, an example output from this program could be: 757) 555-1234 YESs 4. (5 pts) Your program must give the correct (Yes/No) answer when presented with the following phone numbers 757-555-0025 (757)555-1234 75-555-0000 757.555.1234 757-043-1234 057-555-1234 057-MH5-1234 OPTIONAL: If you get your program working and want to challenge yourself further, make the following change: When the program outputs NO have it also output a reason why the string is unacceptable

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution