Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Text Input 377 Listing 9­1 151. 152. 153. 154. 155. 156. 157. 158. 159. 160. 161. 162. 163. 164. Calculator.java (continued) if (lastCommand.equals("+")) result += x; else if (lastCommand.equals("-")) result -= x; else if (lastCommand.equals("*")) result *= x; else if (lastCommand.equals("/")) result /= x; else if (lastCommand.equals("=")) result = x; display.setText("" + result); } private private private private private } JButton display; JPanel panel; double result; String lastCommand; boolean start; java.awt.GridLayout 1.0 · GridLayout(int rows, int columns) · GridLayout(int rows, int columns, int hgap, int vgap)