Input: Decimal Number (n) Output: Binary String (bString) equivalent to the Decimal Number n Process: Initialize to an empty string (tempString=""") Initialize bString to an empty string (bString="") Initialize remainder to 0 (remainder = 0) Assign the decimal number to be converted to n (n = decimal number to be converted) While J{ remainder =n%2 n=n/2 tempString = concatenation of tempString and remainder // tempString = tempString.concat(remainder) } tempString = concatenation of tempString and the current value of n // tempString = tempString.concat(n) bString = reverse of tempString // bString = tempString.reverse() return bString

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 12RQ
icon
Related questions
icon
Concept explainers
Question
Input: Decimal Number (n)
Output: Binary String (bString) equivalent to the Decimal Number n
Process:
Initialize to an empty string (tempString="")
Initialize bString to an empty string (bString="""")
Initialize remainder to 0 (remainder = 0)
Assign the decimal number to be converted to n (n = decimal number to be converted)
While (
J{
remainder =n%2
n = n/2
tempString = concatenation of tempString and remainder // tempString =
tempString.concat(remainder)
}
tempString = concatenation of tempString and the current value of n // tempString =
tempString.concat(n)
bString = reverse of tempString // bString = tempString.reverse()
return bString
Transcribed Image Text:Input: Decimal Number (n) Output: Binary String (bString) equivalent to the Decimal Number n Process: Initialize to an empty string (tempString="") Initialize bString to an empty string (bString="""") Initialize remainder to 0 (remainder = 0) Assign the decimal number to be converted to n (n = decimal number to be converted) While ( J{ remainder =n%2 n = n/2 tempString = concatenation of tempString and remainder // tempString = tempString.concat(remainder) } tempString = concatenation of tempString and the current value of n // tempString = tempString.concat(n) bString = reverse of tempString // bString = tempString.reverse() return bString
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT