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
Construct.
Does a friend function violate the data hiding? Explain briefly. Write a program to swap variables of two classes using friend function. C++
Please fill in the blanks for the following statements: The class function with no return type that is used to initialize data members is called the __________________________.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning