Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions