Convertidor digital a octal
Enviado por Mikki • 8 de Diciembre de 2017 • 693 Palabras (3 Páginas) • 329 Visitas
...
}
btnBotones[i].addActionListener(this);
cpane.add(btnBotones[i]);
}
jrbSistemas[2].setSelected(true);
elegirSistema(10);
frame.pack();
frame.setSize(290,350);
frame.setResizable(false);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private void elegirSistema(int sistema){
for(int i=0;i
if(!btnBotones[i].getText().equals("+")&&
!btnBotones[i].getText().equals("-")&&
!btnBotones[i].getText().equals("*")&&
!btnBotones[i].getText().equals("/")&&
!btnBotones[i].getText().equals("=")){
btnBotones[i].setEnabled(false);
}
}
switch(sistema){
case 2:
for(int i=0;i
if(!btnBotones[i].getText().equals("A")&&
!btnBotones[i].getText().equals("B")&&
!btnBotones[i].getText().equals("C")&&
!btnBotones[i].getText().equals("D")&&
!btnBotones[i].getText().equals("E")&&
!btnBotones[i].getText().equals("F")&&
!btnBotones[i].getText().equals("9")&&
!btnBotones[i].getText().equals("8")&&
!btnBotones[i].getText().equals("7")&&
!btnBotones[i].getText().equals("6")&&
!btnBotones[i].getText().equals("5")&&
!btnBotones[i].getText().equals("4")&&
!btnBotones[i].getText().equals("3")&&
!btnBotones[i].getText().equals("2")){
btnBotones[i].setEnabled(true);
}
}
break;
case 8:
for(int i=0;i
if(!btnBotones[i].getText().equals("A")&&
!btnBotones[i].getText().equals("B")&&
!btnBotones[i].getText().equals("C")&&
!btnBotones[i].getText().equals("D")&&
!btnBotones[i].getText().equals("E")&&
!btnBotones[i].getText().equals("F")&&
!btnBotones[i].getText().equals("9")&&
!btnBotones[i].getText().equals("8")){
btnBotones[i].setEnabled(true);
}
}
break;
case 10:
for(int i=0;i
if(!btnBotones[i].getText().equals("A")&&
!btnBotones[i].getText().equals("B")&&
!btnBotones[i].getText().equals("C")&&
!btnBotones[i].getText().equals("D")&&
!btnBotones[i].getText().equals("E")&&
!btnBotones[i].getText().equals("F")){
btnBotones[i].setEnabled(true);
}
}
break;
case 16:
for(int i=0;i
btnBotones[i].setEnabled(true);
}
break;
}
txtResultado.setText(c.combertirSistema(s, sistema, txtResultado.getText()));
s=sistema;
}
public static void main(String[] args) {
Calculadora c = new Calculadora();
}
public void actionPerformed(ActionEvent e){
if(e.getActionCommand().equals("Cl")){
txtResultado.setText("");
}
if(e.getActionCommand().equals("BIN")){
elegirSistema(2);
d = new Binario();
}
if(e.getActionCommand().equals("OCT")){
elegirSistema(8);
...