Question: C++ programming please!! thx!! 4. [20 marks) Define a function named validatePostal Code that accepts a string including a postal code as its input parameter

 C++ programming please!! thx!! 4. [20 marks) Define a function named
C++ programming please!! thx!!

4. [20 marks) Define a function named validatePostal Code that accepts a string including a postal code as its input parameter and validates it. A postal code is considered valid if it includes 7 characters as specified by the format: "LDL DLD", where L is an alphabetic letter and D is a digit, and the fourth character is a space. This function returns the result of its validation as follows: 1) If the number of characters in the input string is not valid, the function returns -1, otherwise, 2) If the input string includes at least one invalid character, the function returns the index of the first invalid character, otherwise, 3) The function returns -2 to show that the postal code was valid. Here are some examples: The function returns -2 for the input string: VIP 5T8 The function returns -1 for the input string: A5B6 BIOP The function returns 2 for the input string: V14 3M3 The function returns 3 for the input string: V1P5T8P The prototype of this function is as the following: int validate Postal Code (string); After implementing the function, write a program that reads a postal code from the keyboard and calls the validate Postal Code function to validate it and displays a message including the result on the screen. Here are some sample messages: The postal code is valid. Error in the number of characters. Error in the character at the location

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!