(Help) Fraction Summation and Exponents

I'm making a program that's supposed to calculate the sum of this:

http://fc68.deviantart.com/fs36/f/20..._CAA_DP_DA.jpg

Code:

`import java.util.Scanner;`

public class Project5 {

public static void main (String[] args) {

Scanner scan = new Scanner (System.in);

System.out.println ("Enter n: ");

int n = scan.nextInt();

double sum = 0.0;

int x=1;

//I'm not sure if that's right, because I'm trying to make x be the numerator, so it can keep increasing by 1. Should I do that?

while (x<=n) {

if (x%2==1) {

sum += (x/ **how do I say 2 to the power of n?** );

}else{

sum -= (x/ **how do I say 2 to the power of n?** );

}

x++

}

And how do I get it to reach that end summation, of (-1) to the power of n+1?

I'm not even sure if the stuff I have so far can possibly work. I just know that we're not allowed to use "Math.pow". Please help, I can't find any useful examples in my book or notes.