Tavo Gtz

Greenhorn

Posts: 8

posted 4 years ago

Hey guys, Im getting an error, but I just dont see why. Anyone able to help? Im pretty sure its a basic issue, Im just not able to see it.

Im doing a calculator that can convert numeric systems, from binary to decimal, octal, hexadecimal. From decimal to binary, octal, hexadecimal and so all the other combinations.

I believe my problem is in my logical operators.

This is my code so far:

private javax.swing.JTextField Convert; //textfield where I enter the number I want to convert

private javax.swing.JTextField Result;

Res = Integer.parseInt(Convert.getText());

if(Decimal1.isSelected() && Binary2.isSelected())

{Result.setText(Integer.toBinaryString(Res));}

if(Decimal1.isSelected() && Octal2.isSelected())

{Result.setText(Integer.toOctalString(Res));}

else(Decimal1.isSelected() && Hexa2.isSelected())

{Result.setText(Integer.toHexString(Res));}

my radio button group in the left is where Decimal1 exists and on the right Binary2, Octal2, Hexa2

Im doing a calculator that can convert numeric systems, from binary to decimal, octal, hexadecimal. From decimal to binary, octal, hexadecimal and so all the other combinations.

I believe my problem is in my logical operators.

This is my code so far:

private javax.swing.JTextField Convert; //textfield where I enter the number I want to convert

private javax.swing.JTextField Result;

Res = Integer.parseInt(Convert.getText());

if(Decimal1.isSelected() && Binary2.isSelected())

{Result.setText(Integer.toBinaryString(Res));}

if(Decimal1.isSelected() && Octal2.isSelected())

{Result.setText(Integer.toOctalString(Res));}

else(Decimal1.isSelected() && Hexa2.isSelected())

{Result.setText(Integer.toHexString(Res));}

my radio button group in the left is where Decimal1 exists and on the right Binary2, Octal2, Hexa2

Screenshot from 2013-04-19 17:28:24.png

Tavo Gtz

Greenhorn

Posts: 8

posted 4 years ago

If you have 3 mutually exclusive conditions (exactly one of them will be true, no more, no less), then you want this:

However, if it's possible for NONE of them to be true (but still at most one can be true) then you want:

Make sure you understand the difference between

And finally, note that we cannot do

However, if it's possible for NONE of them to be true (but still at most one can be true) then you want:

Make sure you understand the difference between

And finally, note that we cannot do

Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |