Question: Using C++, Write a program that determines whether the user entered an item number in the required format: three digits, a hyphen, and two digits.

Using C++,

Write a program that determines whether the user entered an item number in the required format: three digits, a hyphen, and two digits. Display an appropriate message indicating whether the format is correct. Use a sentinel value to end the program.

Hint: Use substr

Sample Run Item number (e.g. 123-45 or X or x to end): abc Incorrect format. Item number (e.g. 123-45 or X or x to end): abc-de Incorrect format. Item number (e.g. 123-45 or X or x to end): 123 Incorrect format. Item number (e.g. 123-45 or X or x to end): 12345 Incorrect format. Item number (e.g. 123-45 or X or x to end): 123-45 Correct format. Item number (e.g. 123-45 or X or x to end): x 

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!