Hiya, I have a int x = 28492374 and need to add every other digit together and then later do other stuff with the digits like take every other digit and multiple by two then add each digit together. Anways i dont know the method call out a single digit from an int.
Member 785230 0 Newbie Poster
Recommended Answers
Jump to PostYou should know the classes and their methods:
java.lang.Integer
java.lang.Stringfor example:
java.lang.String st = java.lang.Integer.toString(x);
Jump to PostJust a code to sum up all the digits of a number
int n = 232323, sum = 0, d;
while(n!=0)
{
d = n%10;
sum = sum + 10;
n = n/10;
}its a very basic method to extract digits from a number provided the base …
All 6 Replies
Member 785348 0 Newbie Poster
quuba 81 Posting Pro
NormR1 563 Posting Sage Team Colleague
Prateek Jauhari 0 Newbie Poster
NormR1 563 Posting Sage Team Colleague
Prateek Jauhari 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.