The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

help with problem

Posted by andre on October 19, 2001 at 10:10 PM

if someone could help with the following it would be greatly appreaciated, problem:
Write program that allows the user to input a non-negative decimal integer and then displays that value in binary. For example if the user inputs ``13'' the program should output ``1101''.

Hint: The program should use this strategy:

Divide the decimal number by 2, keeping the quotient and the remainder (which will be either 0 or 1).
Prepend the remainder to a string
Keep dividing and prepending the remainder to the string until the quotient is zero.

i have problems with the algoriths, how do i convert the decimal to a binary and then display it in a string? please use the abovestrategy, thanks



Replies:
  • help with problem Chet Underwood, Esq. October 20, 2001 at 3:06 PM (0)
  • hmm Chin Loong October 20, 2001 at 9:23 AM (0)

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us