Question: switch ( calculation ) { case 1 : answer = number + Double.parseDouble ( textField . getText ( ) ) ; if ( Double .

switch (calculation){
case 1:
answer = number + Double.parseDouble(textField.getText());
if (Double.toString(answer).endsWith(".0")){
textField.setText(Double.toString(answer).replace(".0",""));
} else {
textField.setText(Double.toString(answer));
}
label.setText("");
break;
case 2:
answer = number - Double.parseDouble(textField.getText());
if (Double.toString(answer).endsWith(".0")){
textField.setText(Double.toString(answer).replace(".0",""));
} else {
textField.setText(Double.toString(answer));
}
label.setText("");
break;
case 3:
answer = number * Double.parseDouble(textField.getText());
if (Double.toString(answer).endsWith(".0")){
textField.setText(Double.toString(answer).replace(".0",""));
} else {
textField.setText(Double.toString(answer));
}
label.setText("");
break;
case 4:
answer = number / Double.parseDouble(textField.getText());
if (Double.toString(answer).endsWith(".0")){
textField.setText(Double.toString(answer).replace(".0",""));
} else {
textField.setText(Double.toString(answer));
}
label.setText("");
break;
I want to add for this part more parts or a seperate method where I add the following buttons: AND,OR,XOR,NOT,>>,, and I want to perform the operation in a Java GUI calculator by using these and I also want to be able to add the binary number such as the images
1- Your calculator should be able to perform +.../ and * on the binary and hexadecimal numbers.
2- Your calculator should be able to perform logical operations on binary and hexadecimal numbers. For example
switch ( calculation ) { case 1 : answer = number

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!