diff --git a/src/ca/bcit/comp1510/assignment2/q4/Exponential.java b/src/ca/bcit/comp1510/assignment2/q4/Exponential.java index 42607d3..1b80fce 100644 --- a/src/ca/bcit/comp1510/assignment2/q4/Exponential.java +++ b/src/ca/bcit/comp1510/assignment2/q4/Exponential.java @@ -5,18 +5,41 @@ package ca.bcit.comp1510.assignment2.q4; * don't have to write an essay but you should describe exactly what it does. * Describing it will help you to understand the programming problem better.

* - * @author Your Name goes here - * @version 1.0 + * @author Braeden Sowinski + * @version 1.0.0 */ public class Exponential { + + /** + * exp calculates stuff. + * @param x double + * @return double + * */ + public static double exp(double x) { + double r = 1.0; + double t = 1.0; + final double m = 1e-10; + + for (int k = 1; Math.abs(t) > m; k++) { + t *= (x / k); + r += t; + } + + return r; + } + /** * Describe what the main method does here. * * @param args command line arguments */ public static void main(String[] args) { - //replace next line with your code: - System.out.println("Question four was called and ran sucessfully."); + final double min = -10.0; + final double max = 10.0; + for (double i = min; i <= max; i++) { + double x = exp(i); + System.out.println("x = " + i + " e^x = " + x); + } } }