אתה תמיד יכול לקלוט
nextLine() ואז לעשות בדיקה אם הוא באמת מספר ע"י tryboolean takeNum = true
while (takeNum){
try{
int num = Integer.parseInt(sc.nextLine());
takeNum = false
System.out.printf ("Succesfully entered %d", num);
}catach (Exception e){
System.out.printf ("Please enter a valid num");
}
}
כי בעיקרון ה"סיכון" שאתה לוקח כאן זה שמשתמש יכניס לך תו שהוא לא מספר ואז יש סיכוי שהתוכנה שלך תקבל Exception