Question: Chapter 5 Problem 37 (Decimal to Binary) Write a program that prompts the user to enter a decimal integer and displays its corresponding binary value.

Chapter 5 Problem 37 (Decimal to Binary)

Write a program that prompts the user to enter a decimal integer and displays its corresponding binary value. Don't use Java's Integer. toBinaryString(int) in this program. Hint: Program Plan. 1) Enter a decimal integer number. Do NOT use

public static StringBuffer toBinary(int number) { StringBuffer sb = new StringBuffer(); int t=0; while(number>0) { t = number%2; sb.append(t); number = number / 2; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!