From 2ad94f823348492e44fca2f67a6597eb6a09fc3e Mon Sep 17 00:00:00 2001 From: Psycotik Date: Fri, 9 Feb 2024 04:20:15 -0800 Subject: [PATCH] Created Feature01 branch. Created Multadd.java. --- .idea/misc.xml | 2 +- .idea/vcs.xml | 6 ++++++ Java-Assignment-004.iml | 1 + src/Multadd.java | 31 +++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .idea/vcs.xml create mode 100644 src/Multadd.java diff --git a/.idea/misc.xml b/.idea/misc.xml index 639900d..69ace3f 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/src/Multadd.java b/src/Multadd.java new file mode 100644 index 0000000..9091018 --- /dev/null +++ b/src/Multadd.java @@ -0,0 +1,31 @@ +public class Multadd { + + public static double multadd(double a, double b, double c){ + return a * b + c; + } + + public static double expSum(double x) { + + double term1 = multadd(x, Math.exp(-x), 0); + + double term2 = multadd(1, Math.sqrt(1 - Math.exp(-x)), 0); + + return multadd(1, term1, term2); + + } + + public static void main(String[] args){ + //test + System.out.println(multadd(9.7,2.3,6.4)); + + //sin(pi/4) + (cos(pi/4))/2 + System.out.println(multadd(Math.sin(Math.PI / 4), 1 / Math.sqrt(2), Math.cos(Math.PI / 4) / 2)); + + //log10(10) + log10(20) + System.out.println(multadd(1, Math.log10(10), Math.log10(20))); + + //xe^(-x) + sqrt(1 - e^(-x)) where x is 3.6 + System.out.println(expSum(3.6)); + } + +}