public static int getIntWithinRange(Scanner sc, String prompt, int min, int max)
            
    {
        boolean isValid =false;
        int numberofYears = 0;
        
        while(isValid==false)
            
        {
           numberofYears= getInt(sc,prompt);
                if (numberofYears<=min)
                {
                  System.out.println("Error! Number must be greater than "+min);
                  isValid=false;
                  continue; //jump to the the upper loop
                }
                
                else if (numberofYears>=max)
                {
                  // display the error message and prompt the user enter again
                  System.out.println("Error! Number must be less than "+max);
                  isValid=false;
                  continue;
                }
          isValid =true;
        }
     return numberofYears;
    }