convert decimal to binary in java

Decimal to Binary Number Program in Java

import java.util.Scanner; /** * * @author AFAQ */ public class DecimalToBinary { public static void main(String[] args) { int decimal; Scanner sc = new Scanner(System.in); System.out.print(“Enter decimal number=”); decimal = sc.nextInt(); String binary = “”; while (decimal > 0) { binary= decimal % 2 + binary ; decimal = decimal / 2; } System.out.println(“Binary=”+binary); } […]