diff --git a/.idea/misc.xml b/.idea/misc.xml index 639900d..172df7b 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Java-Assignment-004.iml b/Java-Assignment-004.iml index b46c0dd..e1006ff 100644 --- a/Java-Assignment-004.iml +++ b/Java-Assignment-004.iml @@ -5,6 +5,7 @@ + \ No newline at end of file diff --git a/README.md b/README.md index 46e3536..8810ea9 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,4 @@ Follow these steps for submission: 3. Push it to your Remote/origin branch (i.e., GitHub: Feature01 -> origin/Feature01). 4. Issue a Pull request to my instructor repo. 5. **Make sure to COPY the Pull request URL and submit it for the lab/assignment in Canvas.** + diff --git a/src/Multadd.java b/src/Multadd.java new file mode 100644 index 0000000..2b66540 --- /dev/null +++ b/src/Multadd.java @@ -0,0 +1,28 @@ +public class Multadd { + // Performs the MultAdd action + public static double multadd(double a, double b, double c) { + return a * b + c; + } + // Calculates ExpSum + public static double expSum(double x) { + double MinusX = Math.exp(-x); + double first = multadd(x, MinusX, 0); + double second = multadd(1, -MinusX, 0); + return multadd(x, MinusX, Math.sqrt(second)); + } + public static void main(String[] args) { + // Testing multadd method + double result1 = multadd(1.0, 2.0, 3.0); + System.out.println("Testing multadd method:"); + System.out.println("1.0 * 2.0 + 3.0 = " + result1); + // Gets the specified values using multadd + double sincos = multadd(Math.sin(Math.PI / 4), 1 / Math.sqrt(2), 0); + double logsum = multadd(Math.log10(10), Math.log10(20), 0); + System.out.println("\nValues computed using multadd:"); + System.out.println("sin(pi/4) + cos(pi/4)/sqrt(2) = " + sincos); + System.out.println("log10(10) + log10(20) = " + logsum); + // Calculates expSum + double expsum = expSum(1.0); + System.out.println("\nValue of expSum(1.0) = " + expsum); + } +}