private void jBtnDivActionPerformed(java.awt.event.ActionEvent evt) { firstnum = Double.parseDouble(jtxtDisplay.getText()); jtxtDisplay.setText(""); operations="/" else if (operations == "/") { result = firstnum / secondnum; answer = String.format("%.0f", result); jtxtDisplay.setText(answer);
Beginning Java - Unit 2 Math Operators:[^] Be careful when performing integer division. When dividing an integer by an integer, the answer will be an integer (not rounded). Compare these divisions: (5 is an integer while 5.0 is a double) Integer division 8 / 5 = 1 Double division 8.0 / 5.0 = 1.6 Mixed division 8.0 / 5 = 1.6
double
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)