Design an algorithm (no code) just using if-then statement

Assignment Help Data Structure & Algorithms
Reference no: EM13950600

Design an algorithm (no code) just using if-then statement or while statement generically, that validates a US phone number in the form of (xxx) xxx-xxxx.

In many situations, information is supplied as a string of text characters. The characters of that information may need to be in a particular format to be valid. Common examples include credit card numbers, e-mail addresses, dates, and telephone numbers.

Develop an algorithm to verify if a string of characters could represent a valid U.S. phone number. Since determining whether a string of characters is actually a valid phone number is a complex process. Therefore, you will determine only if the characters in the string appear in a format appropriate for such a phone number.

The algorithm should accept any string in the form (xxx) xxx-xxxx, where x represents a digit and the other characters represent themselves, and reject all others. For this algorithm, you can determine the total number of characters in the string and inspect the value of one character at a time.

Provide an example of an input string that is in the proper format and an example that is not in the proper format. Describe how your algorithm determines that the first string is in the proper format and that the second string is not in proper format.

Reference no: EM13950600

Questions Cloud

Who is attempting to teach without inspiring the pupil : A teacher who is attempting to teach without inspiring the pupil with a desire to learn is hammering on cold iron." - Horace Mann
How can business move from mail order to online presence : Apply ethical research and inquiry skills and demonstrate an understanding of the social impact of information technology and the need for security, privacy and ethical implications in information systems usage
Surroundings and the effects of motion and gravity : A pump operating at steady state takes in saturated liquid water at 65 lbf/in.2 at a rate of 10 lb/s and discharges water at 1000 lbf/in.2 The isentropic pump efficiency is 80.22%. Heat transfer with the surroundings and the effects of motion and ..
What qualities would you expect the firm : Would there be a universal list, or would lists differ on a country-by-country basis? what qualities would you expect the firm to be seeking in these managers?
Design an algorithm (no code) just using if-then statement : Provide an example of an input string that is in the proper format and an example that is not in the proper format. Describe how your algorithm determines that the first string is in the proper format and that the second string is not in proper fo..
Prepare consolidated income statements for solvent company : Prepare consolidated income statements including the distribution of income to the controlling and noncontrolling interests for 20X1 and 20X2.
Power developed by the turbine : Water vapor at 6 MPa, 600°C enters a turbine operating at steady state and expands adiabatically to 10 kPa. The mass flow rate is 2 kg/s and the isentropic turbine efficiency is 94.7%. Kinetic and potential energy effects are negligible. Determine..
What is the apr earned on the account : You and your spouse recently purchased a 300,000 home with 75,000 down, and financing the rest using a 30-year mortgage with a nominal interest rate of 4.25%. Mortgage payments are made at the end of each month. How much of the first 3 years of mo..
Short biography of web du bois : What Should Education Teach- W.E.B. Du Bois was the first African American to earn a doctorate from Harvard. He fought for African American rights and cofounded the NAACP. Du Bois sought social, economic and political reforms to expand equality an..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  What step in the proof fails if messages can be duplicated

Show that the relationship in Lemma 6. 19 also holds if mes­ sages can get lost in the channel pq, but not if messages can be duplicated. What step in the proof fails if messages can be duplicated?

  1 describe the differences between our specifications of

1. describe the differences between our specifications of the sorted list adt and the binary search tree adt. 2. write

  Ease of changes in the processing algorithms

Ease of changes in the processing algorithms: For example, line shifting can be performed on each line as it is read from the input device, on all the lines after they have been read, or on demand when the alphabetization requires a new set of shi..

  Question about unix commands

Assume you have a document called records.txt having the list of employee id and workers names. Every line contains a single employee id immediately followed by the employee name in the format Last name, First name.

  What are the benefits of linked lists and objects in

what are the advantages of linked lists and objects in program development and design? how does python utilize these

  Find the corresponding rpn notation

Find the corresponding RPN notation and write the program using PUSH, POP, ADD, MUL, SUB, and DIV stack instructions.

  Describe a o(nlogn)-time algorithm

You are given a set of n real numbers and another real number x. Describe a O(nlogn)-time algorithm that determines whether or not there exist two elements in S whose sum is exactly x. Hint : Doesn't the O(n log n) term make you feel that sorting ..

  An algorithm that will sort a with a worst-case runtime

Let A be an array with n elements such that the first n -sqrt( n) elements are already sorted (though we know nothing about the remaining elements). Give an algorithm that will sort A with a worst-case runtime substantially better than O(n logn).

  Determine the impedances of elements in laplace domain

Redraw the schematics with the impedance of each of the element shown in Laplace domain. Then determine the overall impedance of the entire circuit between the two ends of the shown circuit and express it in Laplace domain as a ratio of two polyno..

  Describe sorting algorithms and how they work

Describe sorting algorithms and how they work

  What is the efficiency of searching for a particular word

Do the same for dictionary whose words are sorted alphabetically. Compare results.

  Evaluate the asymptotic complexity

Evaluate the asymptotic complexity (Big Theta) int terms of n (not sum) for the given code fragment in the average case.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd