import javax.swing.*; // program poweres class Scanner

public class BPIH4E13B
{
     // main method begins execution of Java application
     public static void main( String args[] )
     {            
        // number e = 2.718...
        // ln(x) = (x-1) - (x-1)^2/2+(x-1)^3/3+(x-1)^4/4..
        // for x<2;
        String s; 
        double x=Double.parseDouble(JOptionPane.showInputDialog("Enter a real number: ")); // read number
        double power=1;
        double ln=0;
        double xm1=x-1;;
        int plusminus=-1;
        for(double n=1;n<=10000000;n++)
        {
	    plusminus*=-1;
	    power*=xm1;
        ln+=plusminus*power /n;     
        }
        s="ln("+x+") = "+ln;
        JOptionPane.showMessageDialog(null,s,"natural logarithm calculation",JOptionPane.PLAIN_MESSAGE);
     } // end method main
} // end class BPIH4E1
