import java.util.*;public class Ex1{ public static void main (String [] args) { int age; char r; Scanner sc = new Scanner (System.in); do { System.out.print ("\nPlease enter your age: "); age = sc.nextInt(); /* result is printed by using if statements */ if (age < 0) System.out.print ("Your age can't be negative."); if (age >= 0 && age < 5) System.out.print ("You are too young to be here."); if (age >= 5 && age <= 16) System.out.print ("Why are you there? You should be in school."); if (age > 16 && age <= 150) System.out.print ("You need not be in full-time education. You must like it."); if (age > 150) System.out.print ("You are very old. We should call Guiness world records."); /* program will re-run until user enters 'y' or 'Y' */ System.out.print ("\n\nEnter y or Y to re-run program: "); r = sc.next().charAt(0); } while (r == 'y' || r == 'Y'); }}/* OUTPUTPlease enter your age: 3You are too young to be here.Enter y or Y to re-run program: yPlease enter your age: 9Why are you there? You should be in school.Enter y or Y to re-run program: yPlease enter your age: 17You need not be in full-time education. You must like it.Enter y or Y to re-run program: yPlease enter your age: 155You are very old. We should call Guiness world records.Enter y or Y to re-run program: yPlease enter your age: -5Your age can't be negative.*/