Necesito que me pasen el código de un programa en Java que convierta cualquier número decimal a su número en binario CON ARREGLOS.
5 estrellas!!
GRACIAS.
Por favor, usen arreglos.
PARA QUÉ ARREGLOS?? SI LO QUE QUIERES ES NO USAR EL METODO QUE TRAE JAVA PUES MIRA:
public class Dec2bin {
/**
* @param args the command line arguments
*/
public static void main(String args[]){
Scanner lector = new Scanner (System.in);
int decimal = lector.nextInt();
String binario = "";
while ( decimal > 0 ) {
binario = decimal % 2 + binario;
decimal /= 2;
}
System.out.println(binario);
Cuentame como te va
Espero sirva este link
http://usandojava.blogspot.com/2014/04/conversion-...
saludos
Copyright © 2024 QUIZLIB.COM - All rights reserved.
Answers & Comments
Verified answer
PARA QUÉ ARREGLOS?? SI LO QUE QUIERES ES NO USAR EL METODO QUE TRAE JAVA PUES MIRA:
public class Dec2bin {
/**
* @param args the command line arguments
*/
public static void main(String args[]){
Scanner lector = new Scanner (System.in);
int decimal = lector.nextInt();
String binario = "";
while ( decimal > 0 ) {
binario = decimal % 2 + binario;
decimal /= 2;
}
System.out.println(binario);
}
}
Cuentame como te va
Espero sirva este link
http://usandojava.blogspot.com/2014/04/conversion-...
saludos