public static int getDouble(Scanner sc,String prompt)
    {
        double i = 0;
        boolean isValid = false;
        
        while(isValid==false)
        {
            
            System.out.print(prompt);
            if(sc.hasNextDouble())
                {
                    i=sc.nextDouble();
                    isValid = true;

                }
            
              else 
                {
                    System.out.println("Error! Invalid integer value.Try again.");
                }
                sc.nextLine(); 
        }
        return (int) i;
    }