Here is the code for you: import java.util.*; class PrintNumberWithCommas { public static void main(String[] args) { int number; Scanner sc = new Scanner(System.in); System.out.print(\"Enter an integer between 1000 and 999999: \"); number = sc.nextInt(); while(number < 1000 || number > 999999) { System.out.println(\"Invalid input. Retry...\"); System.out.print(\"Enter an integer between 1000 and 999999: \"); number = sc.nextInt(); } String output = Integer.toString(number); output = output.substring(0, output.length() - 3) + \",\" + output.substring(output.length() - 3); System.out.println(output); } } And the output screenshot is: Solution Here is the code for you: import java.util.*; class PrintNumberWithCommas { public static void main(String[] args) { int number; Scanner sc = new Scanner(System.in); System.out.print(\"Enter an integer between 1000 and 999999: \"); number = sc.nextInt(); while(number < 1000 || number > 999999) { System.out.println(\"Invalid input. Retry...\"); System.out.print(\"Enter an integer between 1000 and 999999: \"); number = sc.nextInt(); } String output = Integer.toString(number); output = output.substring(0, output.length() - 3) + \",\" + output.substring(output.length() - 3); System.out.println(output); } } And the output screenshot is:.