martes, 22 de mayo de 2012

LOS NÚMEROS ROMANOS POR HERENCIA


package javaapplication1;
class unidad
{
    private int numero;
    private String nr;

    public unidad(int numero) {
        this.numero = numero;
    }
    void convetirunidad(int n)
    {
    switch(n){
    case 1: System.out.print("I");
         break;
    case 2:System.out.print ("II");
         break;
    case 3: System.out.print("III");
         break;
    case 4: System.out.print("IV");
         break;
    case 5: System.out.print("V");
         break;
    case 6: System.out.print("VI");
         break;
    case 7: System.out.print("VII");
         break;
    case 8: System.out.print("VIII");
         break;
    case 9:System.out.print ("Ix");
         break;
    default:break;
    }
    }
    void imprimir()
    {
        System.out.println();
    }
}
class decena extends unidad
{

    public decena(int numero, int d) {
        super(numero);
        this.d = d;
    }
    int d;
    void convertirdecena(int n)
    {
        int x=n;
        n=n/10;
        switch(n){
    case 1: System.out.print ("X");
         break;
    case 2: System.out.print ("XX");
         break;
    case 3: System.out.print ("XXX");
         break;
    case 4: System.out.print ("XXXX");
         break;
    case 5: System.out.print ("L");
         break;
    case 6: System.out.print ("LX");
         break;
    case 7: System.out.print ("LXX");
         break;
    case 8: System.out.print ("LXXX");
         break;
    case 9: System.out.print ("LX");
         break;
    default:break;
    }
    convetirunidad(x%10);
}

}
public class Main {

    public static void main(String[] args) {
    decena objdecena=new decena(99,2);
    objdecena.convertirdecena(99);
    System.out.println();
    }

}
}

No hay comentarios:

Publicar un comentario

Nota: solo los miembros de este blog pueden publicar comentarios.