# how to reverse some input from scanner

Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last
• 11-07-2010, 08:05 PM
moncur
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?
• 11-07-2010, 08:08 PM
Fubarable
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!
• 11-07-2010, 08:09 PM
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
• 11-07-2010, 08:10 PM
JosAH
Quote:

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
• 11-07-2010, 08:15 PM
Fubarable
Quote:

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!
• 11-07-2010, 08:20 PM
moncur
Quote:

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
• 11-07-2010, 08:22 PM
moncur
Quote:

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...
• 11-07-2010, 08:37 PM
JosAH
Quote:

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
• 11-07-2010, 08:50 PM
Fubarable
Quote:

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!
• 11-07-2010, 09:06 PM
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?
• 11-07-2010, 09:41 PM
Fubarable
Quote:

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?
• 11-07-2010, 11:02 PM
DarrylBurke
We need a dentist here, a proctologist just doesn't cut it ;)
• 11-07-2010, 11:18 PM
moncur
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?
• 11-07-2010, 11:22 PM
curmudgeon
You still haven't answered the question several folks have been askin' you! Where's the friggin' dentist when you need him??
• 11-07-2010, 11:31 PM
moncur
cause i dont' know what the fuck you guys want from me...
• 11-07-2010, 11:50 PM
curmudgeon
Quote:

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?
• 11-07-2010, 11:59 PM
moncur
i didn't ignore the question... i said what i wanted numerous times....

get an integer
reverse the integer
• 11-07-2010, 11:59 PM
moncur
435 would be 534

are we on the same page now?
• 11-08-2010, 12:00 AM
moncur
4587 would be 7854
• 11-08-2010, 12:17 AM
curmudgeon
Quote:

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?
Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last