LOOP in JAVA cont… JAVA by Ravinder Nath Rajotiya - April 16, 2021April 16, 20210 Loop Controls Here is an example of range validation, but has no control as how many times the user can take to input the correct value Example-1: Input Validation package com.example; import javax.swing.*; public class loopContinued { public static void main(String[] args) { //input validation String input; int number; input= JOptionPane.showInputDialog("Please enter a number" + "between 1 and 100"); number=Integer.parseInt(input); // now let us validate while(number <1 || number >100) // OR operator to check outside range { JOptionPane.showMessageDialog(null, "Not a valid number"); input=JOptionPane.showInputDialog("Please enter a number between 1 and 100"); number = Integer.parseInt(input); } } } Example-2: user control of Loop In the example below, we use control the loop variable package com.example; import javax.swing.*; public class loopContinued { public static void main(String[] args) { //input validation String input; int Maxnumber; input=JOptionPane.showInputDialog("How high should I go to square the number"); Maxnumber = Integer.parseInt(input); System.out.println("number Squareed "); for(int i=1; i<= Maxnumber; i++) { System.out.println( i