a)i got stuck with a qustion which asks for a date input in this format:
DD-MM-YYYY. I used a string to get the date input because the "-" are required, but then i'm not sure how to check that the user only enters dates.

b)another problem i encountered is that the code asks for a numerical input, like a catalogue for books, in the format YYYYNNN, where YYYY is the year which the input is made, and NNN is a unique number to identify the book. For example, if a book is entered into the catalogue in 2007, its catalogue number would be 2007123. The numerical inputs(catalogue number) cannot overlap, i.e., if there is already a 2007234, there cannot be another 2007234, but a 2006234 can still be entered. I'm unsure of how to validate this catalugue number input.

Any help would be greatly appreciated, thanks!

10 Years
Discussion Span
Last Post by Ancient Dragon

For the year in DD-MM-YYYY format, convert day, month and year into individual integers then validate each of them. For example month must be between 1 and 12, day must be between 1 and the maximum number of days in the month (create an array of integers that contain the number of days in each month).

For part b), you will have to keep an array of catalog numbers so that it can be checked each time someone enters a new number. If the number they entered is already in the array then display an error message and ask for another number.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.