Think of a 4 digit number as the sum of 4 numbers. Say the number is 2345
That is the sum of
2000
300
40
5
To strip off the loworder 0, divide the number by 10
40/10 = 4
(300/10)/10 = 3
Type: Posts; User: Norm
Think of a 4 digit number as the sum of 4 numbers. Say the number is 2345
That is the sum of
2000
300
40
5
To strip off the loworder 0, divide the number by 10
40/10 = 4
(300/10)/10 = 3
If you are going to use Strings you should read the API doc for the String class and see what methods it has for working with the characters in the String.
The API doc: Java Platform SE 7
Which method of the two I suggested can you try?
Converting to a String is the easier.
Those are the operators for this. Getting the rightmost digit is easy. I've not tried getting the leftmost first.
Or convert the number to a String and use the String class's methods.
Can you explain and give an example? What is a "particular number"?
Given 1234
Could the "particular number" be the digit in the second position: '2'
Or if the "particular number" is a 3 then...
Can you explain and give an example? Is there a word missing after the word particular?