Hey guys, i'm fairly new here. Just stuck on a program. It seems like it should be right, based on my pseudo code, but something went wrong. Edit: without using Math.pow; Edit: kind of not looking for the answer, just what i did wrong,, other wise, i wont know it for the test.

/**
 * @(#)powerRangers.java
 *
 *
 * @*EDITED MY NAME*
 * @version 1.00 2010/10/8
 */

import java.util.Scanner;
public class powerRangers
{

    /**
     * Creates a new instance of <code>powerRangers</code>.
     */
    public powerRangers()
    {
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
{

    	int value, counter = 0, total, icounter;
    	Scanner scan = new Scanner (System.in);
        // ASK FOR VALUE
        System.out.println("Enter the value");
        value = scan.nextInt();
        icounter = (value - 1);


        while (icounter <= value)
        {
        	total = (2^icounter);
        	System.out.println ("2 to the power: " + counter +" is: " + total);
			counter ++;
        	icounter --;
        }
}
}

Look up what the carrot ^ operator does. To do powers without the math class, consider using a for loop that multiples 2 a certain amount of times.

^ does not do exponents it is a boolean gate function.

What you are probably looking for are shift operators << ,>>, >>> read about those and you should see what to do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.