I was writing a program in which user is supposed to enter double value but I want to prompt the user again if he/she enters a string value.
This is my code so far:
public static void main(String[] args) {
    Scanner input = new Scanner(System.in); 
    double purchaseAmount = 0; 
    if (input.hasNext("mp")) { 
        do { 
            System.out.println("Enter your loan amount: ");
            purchaseAmount = input.next(); 
        } while(!input.hasNextDouble()); 
    }
}
    
 
     
     
     
    