Help with loop to determine e approximation

I used your idea for the factorial, but as a 1st year CSC student, I we haven't learned the power method that you were talking about. I have completed the project though. public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter the number of terms to be used in the approximation of ex -> "); int termNum = sc.nextInt(); System.out.print("Enter the exponent x to approximate ex ->"); double exponent = sc.nextDouble(); System.out.println(); double e = 0; double factorial = 1; double result = exponent; int x = 0; double term1 = 1.0; double finalAnswer = 0;

    if (termNum == 0 || termNum < 0)
        System.out.println(termNum+" is an invalid number of terms.");
    else if (termNum == 1)
    {
        e = 1;
        System.out.printf("e^%.5f ~ %.5f = %.10f%n",exponent,e,e);
    }
    else if (termNum == 2 && exponent > 0)
    {
        e = 1 + exponent;
        System.out.printf("e^%.5f ~ %.5f+%.5f = %.10f%n",exponent,term1,exponent,e);
    }
    else if (termNum == 2 && exponent < 0)
    {
        e = 1 + exponent;
        System.out.printf("e^%.5f ~ %.5f%.5f = %.10f%n",exponent,term1,exponent,e);
    }
    else if (termNum > 2)
    {
        System.out.printf("e^%.5f ~ %.5f+%.5f",exponent,term1,exponent);
        for (int i = 2; i < termNum && x <termNum-1; i++)
        {
            result = result*exponent;
            x++;
            factorial = factorial*i;
            double answers = result/factorial;
            System.out.printf("+%.5f",answers);
            finalAnswer = finalAnswer+answers;
        }
        System.out.printf(" = %.10f%n",finalAnswer+term1+exponent);
    }
}
}
/r/javahelp Thread Parent