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
Get step-by-step solutions from verified subject matter experts
