when running the code, if I input any character other than number, the exeception "java.util.InputMismatchException" gets catched, but next time if I input any character other than number, the program gets terminated with error "Exception in thread "main" java.util.InputMismatchException". how to make it able to catch more than one simultaneous exceptions untill a valid input is given.

```
/*
Twenty students were asked to rate on a scale of 1 to 5 the quality of the food in the
student cafeteria, with 1 being “awful” and 5 being “excellent.” Place the 20 responses
in an integer array and determine the frequency of each rating.
 */
import java.util.Scanner;

public class StudentPoll 
{
    static Scanner input=new Scanner(System.in);
    public static void main(String[] args)
    {
        System.out.println("Rate the quality of food from 1 to 5." +
                "\n1 being “awful” and 5 being “excellent”.\n");
        int[] array=new int[10];
        int num =0;
        for(int i=0;i<array.length;i++)
        {

            do{
                System.out.println("Student "+(i+1)+" Enter Your Response:");
                try
                {
                    num=input.nextInt();
                }
                catch(java.util.InputMismatchException e)
                {
                    System.out.println("Enter numbers only.");
                    input.nextLine();
                    num=input.nextInt();
                }   
                if(num<=0 || num>5)

                {
                    System.out.println("Enter 1 to 5 only.");
                }
            }while(num<=0 || num>5);
            array[i]=num;

        }

        int[] frequency=new int[6];

        for ( int i = 0; i < array.length; i++ )
        {
            frequency[array[i]]=frequency[array[i]]+1;      
        }

        System.out.printf("*    :%d (awful)\n",frequency[1]);
        System.out.printf("**   :%d\n",frequency[2]);
        System.out.printf("***  :%d\n",frequency[3]);
        System.out.printf("**** :%d\n",frequency[4]);
        System.out.printf("*****:%d (excellent)\n",frequency[5]);
    }
}`

```