i am trying to make a program that get input value 1-200 from user.

however i would like to make the program to show warning if the input number is not within the range of 1-200. in the end i would like to show the amount of number according to its interval (i.e less 50, 51-100 and so on)

import java.util.Scanner; class test { public static void main (String[] args) { int number[]= new int[5]; int number2[]= new int[5]; int a=0,b=0,c=0,d=0,i=0; int a2=0,b2=0,c2=0,d2=0,j=0; int a3,b3,c3,d3; Scanner input = new Scanner(System.in); for (i=0;i<5;i++) { System.out.println("Enter Number between 1-200 :"); number[i] = input.nextInt(); if (number[i] <1 || number[i] > 200) { for (j=0;j<1;j++) { System.out.println("Number is invalid, please Enter a New number"); number2[j] = input.nextInt(); j++; if (number2[j] >=1 && number2[j] <50) a2++; else if (number2[j] >=50 && number2[j] <101) b2++; else if (number2[j] >= 101 && number2[j] <151) c2++; else if (number2[j] >= 151 && number2[j] <201) d2++; } } if (number[i] >=1 && number[i] <50) a++; else if (number[i] >=50 && number[i] <101) b++; else if (number[i] >= 101 && number[i] <151) c++; else if (number[i] >= 151 && number[i] <201) d++; } a3 = a +a2; b3 = b +b2; c3 = c +c2; d3 = d +d2; System.out.println("Less than 50 :" +a3 ); System.out.println("50-100 :" +b3); System.out.println("101-150 :" +c3 ); System.out.println("151-200 :" +d3); } }