//My Problem on this is i need the output to be reversed
//Example Run:
//Enter a decimal number
//100
//The Decimal Number is: 100
//Its Binary Representation is:
//0010011
//I need the output to be reversed to 1100100
//Without using the .reverse or .IntegerToBinary methods
//Any help would be appreciated
import java.lang.*;
import java.util.*;
public class BinaryDecimal
{
public static void main(String[ ] args)
{
Scanner keyBoard = new Scanner(System.in);
System.out.println("Enter a decimal number");
int num = keyBoard.nextInt();
System.out.println("The Decimal Number is: " + num);
System.out.println("Its Binary Representation is:");
while(num != 0)
{
int numHold = num / 2;
if (num % 2 == 0)
{
System.out.printf("0");
}
else
{
System.out.printf("1");
}
num = numHold;
}
}
}


Reply With Quote
