A stack can be used to convert decimal numbers to binary numbers. You are to write the
Fantastic news! We've Found the answer you've been seeking!
Question:
public static void displayBinary (int decimalNum){
Stack stck=new Stack();
while decimalNum not equal to 0{
find remainder when decimalNum is divided by 2
push remainder on the stack
divide the decimalNum by 2
}
while stack isn't empty
pop num off the stack and display
}
Use the following header in writing your method displayBinary.
/**
Display the binary representation of decimalNum.
Precondition: decimalNum>0
*/
public static void displayBinary (int decimalNum)
Related Book For
Principles Of Information Security
ISBN: 9780357506431
7th Edition
Authors: Michael E. Whitman, Herbert J. Mattord
Posted Date: