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

  Write algorithm which divides n objects of u into k clusters

Suggest the algorithm which divides n objects of U into k clusters, making use of MST of a graph. Give a simple argument of correctness and bound on the running time of the algorithm you are proposing.

  Calculate the total weights and values of each subset

Use the decrease-by-one technique to generate the power set and calculate the total weights and values of each subset, then find the largest value that fits into the knapsack and output that value.

  Part 11 how many cells can be in a computers main memory if

part 11. how many cells can be in a computers main memory if each cells address can be represented by two hexadecimal

  How many students need to be entered

Write a program that would allow a user to enter student names and Final grades (e.g. A,B,C,D,F) from their courses. You do not know how many students need to be entered

  Organizing the data in ms excel

Many of your family members have discovered that you are using Excel to organize the information for the high school reunion. Your Uncle Larry wants to make an inventory of the over 800 video games that he collects.

  Chinese remainder theory

For RSA signature, let p=17 and q=43. Design a digital signature for the message m=161, where the hashing function is the identity function and the computation at the signer's side is performed through the Chinese Remainder Theory.

  Creating two single dimension arrays

Make two single dimension arrays that contain ten floating point numbers in each array. Make a third single dimension array to hold a sum.

  Irected graph g = (v,e) in which edges that leave the source

Suppose that we are given a weighted, directed graph G = (V,E) in which edges that leave the source vertex s may have negative weights, all weights are nonnegative, and there are no negative-weight cycles. Argue that Dijkstra's algorithm correctly fi..

  Create a flowchart to determine the cause of problems

Assume you are the 1st level help desk technician at a average sized corporations. Your job is to handle the initial calls from corporation  computer users with personal computer related problems.

  Dependency diagram reflects a table that is in

dependency diagram reflects a table that is in

  What are some of the benefits of modularity

What are some of the benefits of modularity? What is functional abstraction? What is information hiding

  Karatsuba''s divide-and-conquer algorithm

In class we discussed Karatsuba's divide-and-conquer algorithm for integer multiplication, which multiplies n-bit numbers by recursively multiplying n bit numbers. We take two numbers X and Y and split them each into their most significant half a..

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