Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/01/2011, 14:55
Tito Millo
 
Fecha de Ingreso: noviembre-2006
Mensajes: 6
Antigüedad: 17 años, 5 meses
Puntos: 0
Programa Para Convertir Numeros Decimales a Binarios

Hola, estoy estudiando Sistemas y pues ya he hecho algunos programas y este es el proyecto de final del semestre.
Lo escribi en Java pero el problema es que aun no se como se hace un interfaz grafica. No se si me pueden dar una mano de como debo hacerlo.
Aqui les dejo el codigo:

Código:
package DecimalBinario;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author Tito Millo
 */
public class Principal {
    public static void main(String[] args) throws IOException {
        int num, coc = 0, res, i = 0;
        int[] vect = new int[50];

        BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));

        System.out.print("Ingrese un número: ");
        num = Integer.parseInt(lector.readLine());

        if (num < 2){
            System.out.println(num);
        }else{
            while (num >= 2){
                coc = num / 2;
                res = num % 2;
                num = coc;
                vect[i] = res;
                i++;
            }
            System.out.print(coc);
            i--;
        }
        while (i >= 0){
            System.out.print(vect[i]);
            i--;
        }
        System.out.println("");
    }

}
Saludos