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
(Combining Class Time and Class Date) Combine the modified Time class of Exercise 17.7and the modified Date class of Exercise 17.8 into one class called DateAndTime. (In Chapter 19, we’lldiscuss inheritance, which will enable us to accomplish this task quickly without modifying the existing class definitions.) Modify the tick function to call the nextDay function if the time increments into the next day. Modify functions printStandard and printUniversal to output the dateand time. Write a program to test the new class DateAndTime. Specifically, test incrementing thetime into the next day.
(Enhancing Class Time) Modify the Time class of Figs. 17.4–17.5 to include a tick memberfunction that increments the time stored in a Time object by one second. Write a program that teststhe tick member function in a loop that prints the time in standard format during each iterationof the loop to illustrate that the tick member function works correctly. Be sure to test the followingcases:a) Incrementing into the next minute.b) Incrementing into the next hour.c) Incrementing into the next day (i.e., 11:59:59 PM to 12:00:00 AM).
(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
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