Java Code
I don't know how to show odd or even digits from an integer number. For example I ask the user to enter a 4 digits integer number. For example the user enter 4875. I want to display odd digits (7 5) and even digits (4 8). By Extract each digit of the number using integer division and store the results in separate variables.
for example, that 4875 is 4*1000+8*100+7*10+5
ki72
0
Newbie Poster
Recommended Answers
Jump to PostBe creative, for example if you read input from user you will get string object. Convert string to character array, read array element by element, convert element to integer and fine out if it is odd or even number.
Jump to PostIn addition to what Peter said, you might find some of the responses here helpful: http://www.daniweb.com/forums/thread232056.html
All 5 Replies
peter_budo
2,532
Code tags enforcer
Team Colleague
Featured Poster
BestJewSinceJC
700
Posting Maven
Clawsy
1
Posting Whiz in Training
Clawsy
1
Posting Whiz in Training
peter_budo
2,532
Code tags enforcer
Team Colleague
Featured 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.