How do I write a program to test input validation. The program asks the user for the month (by name), and validating that the number of hours entered for the month is not more than the maximum for the entire month. The user is not allowed to enter more than those hours. Here is a table of the months, their days, and number of hours in each.
January, March, May, July, August, October 31 days 744 hours
April, June, September, November 30 day 720 hours
February 28 672 hours
That's not what enums are for. What you're looking for is a map.
With C++11, you can do the following: std::map<std::string,int> monthHourMap{{"JAN",744},{"FEB",675},...};
Then you can retrieve the hours for a month as follows: int months=monthHourMap[input];
With the old C++ standard, you have to initialize the map using an array or with the following: