File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Difficult01/Question 2.20 Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .util .List ;
2
+ import java .util .ArrayList ;
3
+ import java .util .Scanner ;
4
+
5
+ public class SplitNumber {
6
+
7
+ private Scanner keyboardInput ;
8
+ private int testNumber ;
9
+
10
+ public SplitNumber () {
11
+ keyboardInput = new Scanner (System .in );
12
+
13
+ System .out .println ("Enter the number to split" );
14
+ testNumber = keyboardInput .nextInt ();
15
+
16
+ //get a number say 697
17
+ int highestPlaceValue = (int )Math .pow (10 , (Integer .toString (testNumber )).length ());
18
+ List <Integer > integers = new ArrayList <Integer >();
19
+
20
+ for (int i =1 ; i <highestPlaceValue ; i =i *10 ) {
21
+ int temp = testNumber /10 ;
22
+ integers .add (0 , testNumber %10 );
23
+ testNumber = temp ;
24
+ }
25
+ System .out .println (integers );
26
+ }
27
+
28
+ public static void main (String [] args ) {
29
+ SplitNumber numberSplit = new SplitNumber ();
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments