# Thread: how to reverse some input from scanner

1. Member
Join Date
Oct 2010
Posts
26
Rep Power
0

## how to reverse some input from scanner

i want to ask a user to input some integers:

1234

then i want to reverse the order and output like this:

4321

how do i go about doing this? and how do i go about solving a problem like this without asking people how to figure it out?

2. By looking in the String API. There you'll find methods that will help you solve this problem.

Please let us know how this turns out. Luck!

3. Member
Join Date
Oct 2010
Posts
26
Rep Power
0
ok i found it... at first i just ctrl f (reverse) and it didn't find anything... then i clicked integer and found it under there.. thanks

4. Originally Posted by moncur
i want to ask a user to input some integers:

1234

then i want to reverse the order and output like this:

4321

how do i go about doing this? and how do i go about solving a problem like this without asking people how to figure it out?
Before you go ask questions to someone else, ask yourself the question how you want to output the reverse of, say, 1230 or 1200 or 1000.

kind regards,

Jos

5. Originally Posted by moncur
ok i found it... at first i just ctrl f (reverse) and it didn't find anything... then i clicked integer and found it under there.. thanks
Hm, I'm not sure what this means. If you get stuck please clarify. Best of luck!

6. Member
Join Date
Oct 2010
Posts
26
Rep Power
0
Originally Posted by JosAH
Before you go ask questions to someone else, ask yourself the question how you want to output the reverse of, say, 1230 or 1200 or 1000.

kind regards,

Jos
i did...

input as int: 1234
output as int: 4321

7. Member
Join Date
Oct 2010
Posts
26
Rep Power
0
Originally Posted by Fubarable
Hm, I'm not sure what this means. If you get stuck please clarify. Best of luck!
means... when i was on the API website... i tried to find reverse on main page... and nothing came up... then under integer class i found the reverse...

8. Originally Posted by moncur
i did...

input as int: 1234
output as int: 4321
And what about 1230 or 1200 or 1000? Should they show up a 321, 21 and 1 or as 0321, 0021 and 0001?

kind regards,

Jos

9. Originally Posted by moncur
means... when i was on the API website... i tried to find reverse on main page... and nothing came up... then under integer class i found the reverse...
I second JosAH's recommendation as your current code will probably fail with his tests.

I should have been more specific. Check out the String API, not the main page, and don't look for a reverse method, but rather methods that allow you to loop through your String in a for loop and get char at specific locations.

Luck!

10. Member
Join Date
Oct 2010
Posts
26
Rep Power
0
Write a method reverse that accepts an int number and returns an int with the digits in reverse order. For example,
int revNum = reverse( 1234 ); // revNum has a value of 4321

is this better?

11. Originally Posted by moncur
Write a method reverse that accepts an int number and returns an int with the digits in reverse order. For example,
int revNum = reverse( 1234 ); // revNum has a value of 4321

is this better?
?
Your statement above simply states the requirements. Again, have you tested your code with JosAH's test values? What happens when you do?

12. We need a dentist here, a proctologist just doesn't cut it ;)

13. Member
Join Date
Oct 2010
Posts
26
Rep Power
0
ok new question... how do you get the length of input from a scanner input that is only integers?

example:

user enters: 1234

how do i get the length of 1234?

14. Senior Member
Join Date
May 2010
Posts
436
Rep Power
5
You still haven't answered the question several folks have been askin' you! Where's the friggin' dentist when you need him??

15. Member
Join Date
Oct 2010
Posts
26
Rep Power
0
cause i dont' know what the fuck you guys want from me...

16. Senior Member
Join Date
May 2010
Posts
436
Rep Power
5
Originally Posted by moncur
cause i dont' know what the **** you guys want from me...
Then maybe you should say so rather than ignoring the question. Most here assume that you have solved your problem using method from integer. They're simply asking you to test your current code with the numbers that JosAH provided and that you report here on the result of this test. Was that so f***in hard to figure out?

17. Member
Join Date
Oct 2010
Posts
26
Rep Power
0
i didn't ignore the question... i said what i wanted numerous times....

get an integer
reverse the integer

18. Member
Join Date
Oct 2010
Posts
26
Rep Power
0
435 would be 534

are we on the same page now?

19. Member
Join Date
Oct 2010
Posts
26
Rep Power
0
4587 would be 7854

20. Senior Member
Join Date
May 2010
Posts
436
Rep Power
5
Originally Posted by JosAH
And what about 1230 or 1200 or 1000? Should they show up a 321, 21 and 1 or as 0321, 0021 and 0001?

kind regards,

Jos
sigh,.... what about 1230, 1200, or 1000?

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•