I am having difficulties in getting my program working properly. For the part of the project I am having difficulties with, I need to create a function that validates two different numbers input by the user. However in the whenever I run the program I get two errors going on.
One is that the input is first read as me inputting 0 (even though I didn't)
And the second is that it treats it runs the first input through the second inputs validation test
Function prototypes:
int validate(int , int);
Main:
do
{
//display the menu
displayMenu();
cin >> choice;
validate(choice, months);
// process the user's choice
if (choice != QUIT_CHOICE)
{
// get the number of months
cout << over3 << "For how many months? ";
cin >> months;
validate(choice, months);
}
And the function prototype in question:
int validate(int choice, int months)
{
while (choice < 1 || choice > 4)
{
cout << over3 << choice << " is not between 1 and 4! Try again: ";
cin >> choice;
}
while (months < 1 || months > 12)
{
cout << over3 << months << " is not between 1 and 12! Try again: ";
cin >> months;
}
}