I am trying to write a method to calculate a value raised to an integer power. I need to display all the sines ( out to six decimal places, I assume you would use df.format?) for the angles 0 to 90 and also display the Math.sin values for the same angles. Basically I don't know how to complete the Pow method. Any help is appreciated, thanks.


Code:
public class MyMath 
{

	public static void main(String[] args) 
	{
		// test methods here
		for (int j = 0; j <= 90; j ++)
		{
			System.out.println( j + " factorial is " + Factorial(j));
		}
		
	}
	public static double Sine(double x)
	{
		//setup for loop
		double ans = 0;
		double term = x;
		int n = 1;
		//the while loop
		while ( Math.abs(term) > 0.0000001 )
		{
			//do work
			ans = ans * term;
			//get ready inc n, calc term
			n++;
			term = Pow(-1,n+1)* Pow(x, 2*n - 1)/Factorial(2*n - 1);
		}
		//return ans
		return ans;
		
	}
	
	public static double Factorial(int n)
	{
		if (n < 0)
		{
				return -1.0;
		}
		double ans = 1.0;
		
		for(int i = 1; i <= n; i++)
		{
				ans = ans * i;
		}
		return ans;
	}
	
	public static double Pow(double base, int n)
	{
		
	}

}