I used the existing computeButton, nField, and loopLabel from the previous exercise. I have not changed the name of these objects, but good programming practice will name objects something that will help the programmer understand the structure of the code and to debug it.
double f(double x){ return Math.sin(x); } double fdot(double x){ return Math.cos(x); } private void computeButtonMouseClicked(java.awt.event.MouseEvent evt) { double x=Convert.toDouble(nField.getText()); while (Math.abs(f(x))>1.0e-12){ x=x-f(x)/fdot(x); } loopLabel.setText("root is "+x); }