source file name: SumSeries3.java

import java.io.*;

class A

{

int n;

public A(int m)

{

n=m;

}

public void sum()

{

float sum=1.0f;

float i=n;

while(i>0)

{

float p=(int)Math.pow(2,i);

sum=sum+(1/p);

//System.out.println(p+","+sum);

i--;

}

System.out.println(" Series Sum: "+sum);

}

}

class SumSeries3

{

public static void main(String args[])

int i;

i=Integer.parseInt(args[0]);

A ob=new A(i);

ob.sum();

}

}

output: 

D:\JavaPrograms\Constructors>javac SumSeries3.java

D:\JavaPrograms\Constructors>java SumSeries3 5
series Sum: 1.96875