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

public class BPIH4HW3
{
     // main method begins execution of Java application
     public static void main( String args[] )
     {            
        // ln(x) = 1+y^2/3+y^4/5+y^6/7+...   y=(x-1)/(x+1)
        String s; 
        
        double x=Double.parseDouble(JOptionPane.showInputDialog("Enter a real number: ")); // read number
        double power=1;
        double ln=1;
        double y=(x-1)/(x+1);
        int plusminus=-1;
        double n=1;
        do
        {
	    power*=y*y;
        ln+=power /(2.0*n+1.0);     
        n++;
        } while(n<=10000000);
        ln*=2*y;
        s="ln("+x+") = "+ln+"   "+Math.log(10);
        System.out.println(s);
        JOptionPane.showMessageDialog(null,s,"natural logarithm calculation",JOptionPane.PLAIN_MESSAGE);
     } // end method main
} // end class BPIH4E1
