C++ How to Program (10th Edition)
C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
Question
Book Icon
Chapter 21, Problem 21.25E
Program Plan Intro

Checking Validity of Social Number

Program Plan:

  • Include the required header files.
  • Declare the prototype of the function isValidSocialSecurityNumber.
  • Define the “isValidSocialSecurityNumber()” function.
    • Check whether str1.length()!=11 or str1.find_first_of("-")!=3 or str1.find_last_of("-")!=6.
      • If so then return false.
    • Traverse through str1.
      • If i is ‘-‘ at locations 3 or 6 then continue.
      • If the traversed character is not a digit then return false.
    • Return true.
  • Define the “main()” function
    • Create a string variable s and assign the social security number to it.
    • Make a call to function isValidSocialSecurityNumber with s and assign to ans.
    • If value of ans is 1 then display valid message.
    • Else display invalid message.

Blurred answer
Students have asked these similar questions
(Enhancing Class Rectangle) Create a more sophisticated Rectangle class than the one youcreated in Exercise 17.11. This class stores only the Cartesian coordinates of the four corners of therectangle. The constructor calls a set function that accepts four sets of coordinates and verifies thateach of these is in the first quadrant with no single x- or y-coordinate larger than 20.0. The set function also verifies that the supplied coordinates do, in fact, specify a rectangle. Provide member functions that calculate the length, width, perimeter and area. The length is the larger of the twodimensions. Include a predicate function square that determines whether the rectangle is a square
(Richer Shape Hierarchy) The world of shapes is much richer than the shapes included inthe inheritance hierarchy of Fig. 19.3. Write down all the shapes you can think of—both two-dimensional and three-dimensional—and form them into a more complete Shape hierarchy with asmany levels as possible. Your hierarchy should have the base class Shape from which class TwoDimensionalShape and class ThreeDimensionalShape are derived. [Note: You do not need to write any codefor this exercise.] We’ll use this hierarchy in the exercises of Chapter 20 to process a set of distinctshapes as objects of base-class Shape. (This technique, called polymorphism, is the subject ofChapter 20.)
(Java) Q 5,6 Explain the answer step-by-step . I want to understand how to do it so please include verbal explanation. Thank you!   Part 1 Write the class described below: The name of the class is Student The class has two public member variables: A String called name and a double called gpa  The class has a public member method called printStudent. This method prints out the message: "Hi! My name is " + name + ".\nAnd my gpa is " + gpa It returns nothing Part 2  Now, declare a new Student object named jackie, and assign it the values "Jackie Chan" for the name and 3.5 for the gpa.   Finally insert the object jackie into the below ArrayList: ArrayList<Student> al = new ArrayList<Student>();
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education