In: Computer Science
IN JAVA PROGRAMMING
Write a complete Java program to do the following:
a) Prompt the user to enter a six-digit integer.
b) Take the integer and break it up into two pieces of three-digits each (make sure you keep the order of digits).
c) Display each 3-digit piece on a separate line with a proper message before each piece.
For example, if the user enters 450835 as the integer, then the program should display the following output:
Right 3-digit piece: 835
Left 3-digit piece: 450
Given below is the code for the question. Please do rate the answer if it helped. Thank you.
SplitNumber.java
------------------
import java.util.Scanner;
public class SplitNumber
{
public static void main(String[] args){
Scanner input = new
Scanner(System.in);
String num, right, left;
System.out.print("Enter a six-digit
integer: ");
num = input.next();
left = num.substring(0, 3);
right = num.substring(3);
System.out.println("Right 3-digit
piece: " + right);
System.out.println("Left 3-digit
piece: " + left);
}
}