Ok. this is my first tutorial so i hope that you will understand.
How this programme works:
So here is code:
How this programme works:
- Input - decimal number
- output - binary number
So here is code:
import java.util.*;
public class number{
public static void main (String [] args)
{
Scanner input = new Scanner (System.in);
System.out.println ("Input decimal number");
int decimal = input.nextInt ();
input.close ();
int base = 2;
int result = 0;
int multiplier = 1;
while (decimal>0)
{
int residue = decimal%base;
decimal = decimal/base;
result = result +residue*multiplier;
multiplier = multiplier * 10;
}
System.out.println ("binary....."+result);
}
}
No comments:
Post a Comment