Sunteți pe pagina 1din 1

long numero1,numero2,suma;

int i=0,j=0,k=0;
long constante,constante1,constante2;
long residuo,residuo1,residuo2;
int acarreo=0;
numero1=Long.parseLong(this.jTextField1.getText());
numero2=Long.parseLong(this.jTextField2.getText());
DefaultTableModel tabla= new DefaultTableModel();
tabla.setRowCount(4);
tabla.setColumnCount(15);
constante=numero1*10;
constante1=numero2*10;
suma=numero1+numero2;
constante2=suma*10;
while(constante/10>0){
residuo=constante%10;
constante=constante/10;
i++;
tabla.setValueAt(residuo,1,15-i);
}
tabla.setValueAt(numero1/(int)Math.pow(10,i-1),1,15-(i+1));
tabla.setValueAt("",1,14);
while(constante1/10>0){
residuo1=constante1%10;
constante1=constante1/10;
j++;
tabla.setValueAt(residuo1,2,15-j);
}
tabla.setValueAt(numero2/(int)Math.pow(10,j-1),2,15-(j+1));
tabla.setValueAt("",2,14);
while(constante2/10>0){
residuo2=constante2%10;
constante2=constante2/10;
k++;
tabla.setValueAt(residuo2,3,15-k);
}
tabla.setValueAt(suma/(int)Math.pow(10,k-1),3,15-(k+1));
tabla.setValueAt("",3,14);
this.jTable1.setModel(tabla);
}

S-ar putea să vă placă și