/** The program calculates the exponential function e^x where x is a value
 *  input by the user of the program.
 */

package exponentialfunction;

import java.util.Scanner;
/**
 *
 * @author k8port
 */
public class ExponentialFunction {
    
    /** Returns the value of the exponential function with the exponent as    
     *  the parameter. The function is: 1 + x + x^2/2! + x^3/3! + ... + x^n/n!.
     *  @param x An integer value x.
     *  @param x An integer value n.
     *  @return the result of e^n for .
     */ 
    private static double ExpFx(int x, int n) {
        int[] factorial = new int[n];
        int[] exp = new int[n];
        int f = 1, e =1;
        double result = 1;
        for (int i = 1; i <= n; i++) {
            f *= i;
            e *= e;
            factorial[i-1] = f;
            exp[i-1] = e; 
        }
        for (int j = n; j > 1; j--) 
            result += exp[n] / factorial[n];
        return result;
    }
    
    private static final int[] INPUT = {1, 10, 50, 100}; 
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        // instance variables
        Scanner scan = new Scanner(System.in);
        int x; // user input value to solve 
        String ans; // user input yes or no 'y' or 'n'
        boolean go = true; // flag to determine on and off status of program
        
        // gather data
        System.out.println("Tool for calculating the exponential function.");
        do {
            System.out.println("Please input a value x to calculate e^x.");
            x = scan.nextInt();
        
            // solve the equation for inputs 1, 10, 50 and 100
            for (int i = 0; i < INPUT.length; i++) {
                System.out.println("For input of " + INPUT[i] + ":");
                System.out.println(ExpFx(x, INPUT[i]));
            }
            System.out.println("Would you like to quit? y or n.");
            ans = scan.next();
            if (ans == "yes")
                go = false;
        } while (go);
    
    }
}

@@ -105,16 +105,78 @@
 program.
+ %0A *  The function is: 1 + x + x%5E2/2! + x%5E3/3! + ... + x%5En/n!.
 %0A */%0A%0Apa
@@ -229,16 +229,48 @@
 canner;%0A
+import java.text.DecimalFormat;%0A
 /**%0A *%0A 
@@ -333,289 +333,65 @@
     
-%0A    /** Returns the value of the exponential function with the exponent as    %0A     *  the parameter. The function is: 1 + x + x%5E2/2! + x%5E3/3! + ... + x%5En/n!.%0A     *  @param x An integer value x.%0A     *  @param x An integer value n.%0A     *  @return the result of e%5En for .
+/**%0A     * @param args the command line arguments
 %0A     */
  %0A  
@@ -386,37 +386,35 @@
 %0A     */
- 
 %0A    p
-rivate
+ublic
  static 
 double E
@@ -409,631 +409,133 @@
 tic 
-double ExpFx(int x, int n) %7B%0A        int%5B%5D factorial = new int%5Bn%5D;%0A        int%5B%5D exp = new int%5Bn%5D;%0A        int f = 1, e =1;%0A        double result = 1;%0A        for (int i = 1; i %3C= n; i++) %7B%0A            f *= i;%0A            e *= e;%0A            factorial%5Bi-1%5D = f;%0A            exp%5Bi-1%5D = e; %0A        %7D%0A        for (int j = n; j %3E 1; j--) %0A            result += exp%5Bn%5D / factorial%5Bn%5D;%0A        return result;
+void main(String%5B%5D args) %7B%0A        %0A        // instance variables
 %0A    
-%7D%0A
     
-%0A    private static final int%5B%5D INPUT = %7B1, 10, 50, 100%7D; %0A    %0A    /**%0A     * @param args the command line arguments%0A     */%0A    public static void main(String%5B%5D args) %7B%0A        %0A        // instance variables
+DecimalFormat decimal = new DecimalFormat(%22#0.00%22);
 %0A   
@@ -586,19 +586,22 @@
         
-int
+double
  x; // u
@@ -758,16 +758,220 @@
 program%0A
+        double result; // variable to store result of function%0A        int n = 1; // inputs of n for the exponential function%0A        double num, den; // numerator and denominator of exponential function%0A
         
@@ -1121,34 +1121,77 @@
 ln(%22
-Please input a value x to 
+Input a positive whole positive number x to %22%0A                    + %22
 calc
@@ -1233,11 +1233,14 @@
 next
-Int
+Double
 ();%0A
@@ -1251,72 +1251,246 @@
     
-%0A            // solve the equation
+    while (n %3C= 100 && n %3E= 1) %7B%0A                result = 1 + x;%0A                num = x;%0A                den = n;%0A                if (n %3E 1) %7B%0A                   
  for 
+(
 in
-puts 1, 10, 50 and 100%0A
+t i = 2; i %3C= n; i++) %0A                        num *= num;%0A        
     
@@ -1510,40 +1510,181 @@
 int 
-i = 0; i %3C INPUT.length; i++) %7B%0A
+j = n-1; j %3E 0; j--) %0A                        den *= j;%0A                    result += num / den; %0A                %7D  %0A                if (n %3C= 10 %7C%7C n == 50 %7C%7C n == 100) %0A  
     
@@ -1719,111 +1719,158 @@
 ln(%22
-For input
+The value
  of 
+e%5E
 %22 + 
-INPUT%5Bi%5D + %22:%22);%0A                System.out.println(ExpFx(x, INPUT%5Bi%5D));%0A            %7D
+x + %22 when n is %22 %0A                          + n + %22: %22 + decimal.format(result));%0A                n++; %0A            %7D%0A            
 %0A   
@@ -1923,21 +1923,24 @@
  quit? y
+es
  or n
+o
 .%22);%0A   
@@ -1990,18 +1990,33 @@
 (ans
- == 
+.equalsIgnoreCase(
 %22yes%22)
+)
 %0A   

Update ExponentialFunction.java