Recognize a string typed in as a valid or invalid

Assignment Help C/C++ Programming
Reference no: EM13890646

I need this done ASAP. If you can, try to make the code as simple as possible. I am not looking for something complex.

HOMEWORK

"On my honor, as an Aggie, I have neither given nor received any unauthorized aid on any portion of the academic work included in this assignment."

NOTE:  Every program from now on must include at least the exception-handling framework on page 152!  If you add another catch clause, it must precede all more general clauses; for example, if you add catch(Bad_area) it should come before the other two catch clauses.

1. Modify the code in section 23.7 to use a regex to recognize a string typed in as a valid or invalid ISBN-13 book number.  Every valid ISBN-13 book number has the following four parts:

     978 or 979

     nine digits; any digit can be preceded by an optional hyphen or space

     an optional hyphen or space

     one digit or the letter X

A sample run of your program should look like this:

     Enter ISBN: 978-1-84356-028-3

     That is a valid format.

     Enter ISBN: 978-0-684-84328-5

     That is a valid format.

     Enter ISBN: 978-0-8044-2957-X

     That is a valid format.

     Enter ISBN: 979-845-4087-3256

     That is not a valid format.

Name your program hw7pr1.cpp.

2. Modify problem 1 to use regex to recognize valid Social Security numbers.  A valid Social Security number consists of three digits, an optional hyphen, two digits, an optional hyphen, and four digits.  Make each of the three number fields a submatch (put it in parentheses) to check the following constraints:

If any of the three number fields is all zeroes, the number is not a valid Social Security number.  (Yes, that's why your UIN has OO in the second field!)

The first number field cannot be 666 or any number in the range 9OO-999.

The numbers

O42-68-4425,

O78-O5-112O,

123-45-6789,

111-11-1111,

222-22-2222,

333-33-3333,

444-44-4444,

555-55-5555,

777-77-7777,

888-88-8888, and

987-65-432x (where x is any digit O-9)

are invalid.

A sample run of your program should look like this:

Enter a Social Security Number: 666-55-4444

That number is invalid.

Enter a Social Security Number: 457555462

That number is valid.

Enter a Social Security Number: 4575554621

That number is invalid.

Name your program hw7pr2.cpp.

Reference no: EM13890646

Questions Cloud

Determine the effective interest rate corresponding : Determine the effective interest rate corresponding to the 12% per year, compounded continuously. Determine the effective annual interest rate if the nominal interest rate is 15%, compounded monthly. Determine the effective annual interest rate if th..
Proposals are being floated to restrict eminent domain : Proposals are being floated to restrict eminent domain. Incredibly, some people suggest that eminent domain be used only for government projects such as schools. Cities would be limited to taking land off the tax rolls for tax-free development, there..
Has the development of digital technologies democratized : Has the development of digital technologies democratized the art of photography? How has this affected our appreciation of the photographer as artist and photography as an art form? Explain using specific examples.
Review the article-the life of a police officer : Review the article, "The Life of a Police Officer: A Developmental Perspective."
Recognize a string typed in as a valid or invalid : Use regex to recognize valid Social Security numbers.  A valid Social Security number consists of three digits, an optional hyphen, two digits, an optional hyphen, and four digits.
An agent of the employer : How does one know if someone is the authorized agent or another?  For instance, if I own a shop and have an employee in training who has specific instructions NOT to sell anything without running it by  me first, and they do sell it, was the sell val..
Paper - women in combat : For the topic of your paper, you must select one of the following DISCUSSION CASES from your text as the issue focus for your paper: Defining Marriage", "Women in Combat", "Imprisonment"and "Animal Experimentation"
Businesses come in all sizes from small businesses : Businesses come in all sizes, from small businesses like local restaurants, local hair salons, dry cleaners, and others, to franchise and corporations. This project covers these types of businesses and the legal details of their organizational struct..
What type of tax entity dawn should choose for ctc : Dawn wants to know what type of tax entity they should choose for CTC. Write a professional memorandum fully explaining those options.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Display a list of items and the location in the store

The program should display a list of items and the location in the store. The user must be able to enter the items and location in the store. You will use a class for the items. For this assignment you will implement creating the list, adding eleme..

  Write the entire definition for the main function

Write the entire definition for the main function that prints out all of the command-line arguments on its own line.

  Write a program to display the total salary for assistant

Write a program to display the total salary for assistant professors, associate professors, full professors, and all faculties, respectively, and show the average salary for assistant professors, associate professors, full professors, and all facu..

  Write a program to find value of sin

Write a program to find value of sin(x) using expansion series given below by using a function.

  Consider the following nested loop construct

Consider the following nested loop construct. Categorize its efficiency in terms of the variable n using big-O notation. Suppose the statements represented by the ellipsis require four main memory accesses (each requiring one microsecond) and two dis..

  Determine the other operations

(a) {C2(z), C2(x)}, determine the other operations that must be present to form a complete point group. [Hint: Consider all of the products of the given elements with themselves and each other.]

  1 what is the output of the following c programsnbspinclude

1. what is the output of the following c programs?nbspinclude ltiostreamgtusing namespace stdint mainnbspnbspnbsp cout

  Give examples of pretest and posttest loops

Give examples of pretest and posttest loops - Discuss the syntax of while, for, and do...while loops. Give examples.

  Write a c program to calculate

Write a C program to calculate the following Sum: Sum=1-x2/2! +x4/4!-x6/6!+x8/8!-x10/10! */

  Given a character code to indicate the type of customer

Pete's Plumbing of Pompey sells to both retail and wholesale buyers. The retail buyer must pay New York State and Onondaga County sales tax (8%). However, the wholesale buyer does not pay sales tax and receives a volume discount on the amount purchas..

  After the array is created and loaded

After the array is created and loaded, the problem is then to sort the array and print out the contents of the sorted array. Please use a separate function for the sort routine and also a separate function for the print out of the array.

  Make 2-dimensional array

make 2-dimensional array a bit of life and bringing them from the abstract to the concrete realms

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd