So far in my code I prompt the user to enter a positive integer representing the number of people they are inviting to an event. I already have an if statement to return an error message if the user input is a negative value. But how do I return an error message if the user enters a character, string, or double? Whenever I test this by entering a letter, the terminal just displays the following message:
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:909)
at java.util.Scanner.next(Scanner.java:1530)
at java.util.Scanner.nextInt(Scanner.java:2160)
at java.util.Scanner.nextInt(Scanner.java:2119)
at Cookies.main(Cookies.java:15)