Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ String Processing How do you determine if a string value is valid or not? You would have to dismantle the string according to

In C++

String Processing

How do you determine if a string value is valid or not? You would have to dismantle the string according to a set of validity rules. Writing a series of convoluted Ifs, Else Ifs, ANDs, OR tests is not practical nor easily updated or maintained. What other approach is there ?

Determine if the ID string codes are valid:

  1. ID codes consists of Five characters positions (anything less than 5 positions is invalid)
  2. The first two positions must be Letters (A Z)
  3. The last three positions consist of Digit symbols (0 to 9)
  4. Upper and lower case letters are the same (A is the same as a)
  5. NOT all ID patterns are valid. The following are valid ID patterns:
    1. A, K, S - Followed by B, C, D, Followed by 101 to 110
    2. B, H, N - Followed by A, F, G, H, Followed by 113 to 118 or 213 or 220 or 560 or 890
    3. C or T - Followed by K, L, Z, Followed by 134, 138, 145 or 246
    4. M, O, Z - Followed by A, D, F, Followed by 177 to 181 or 333 to 335
    5. Any other pattern is not valid
  6. User enters an ID code and the application will display that it is Valid or Invalid
  7. A large number of IFelse statements is not practical (26 X 26 X 10 X 10 X 10 possibilities) page: 559, character array holding X amount of values and setting the format

Example Output:

Valid Customer ID Rules:

1 - A, K, S - Followed by B, C, D, Followed by 101 to 110

2 - B, H, N - Followed by A, F, G, H, Followed by 113 to 118 or 213 or 220 or 560 or 890

3 - C or T - Followed by K, L, Z, Followed by 134, 138, 145 or 246

4 - M, O, Z - Followed by A, D, F, Followed by 177 to 181 or 333 to 335

Enter a Customer ID: AB107

Customer ID is AB107

Customer ID is Valid

Hit Any Key to continue...

Validate Another ID (Y or N): y

Valid Customer ID Rules:

1 - A, K, S - Followed by B, C, D, Followed by 101 to 110

2 - B, H, N - Followed by A, F, G, H, Followed by 113 to 118 or 213 or 220 or 560 or 890

3 - C or T - Followed by K, L, Z, Followed by 134, 138, 145 or 246

4 - M, O, Z - Followed by A, D, F, Followed by 177 to 181 or 333 to 335

Enter a Customer ID: MF201

Customer ID is MF201

Invalid Digits (Must be 177 to 181, 333 to 335)...

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

More Books

Students also viewed these Databases questions

Question

Which is smallest? a . . 0 8 b . . 0 8 c . 0 0 8 d . . 8 0

Answered: 1 week ago

Question

2. Outline the business case for a diverse workforce.

Answered: 1 week ago