Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Java-Assignment-004.iml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.**

28 changes: 28 additions & 0 deletions src/Multadd.java
Original file line number Diff line number Diff line change
@@ -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);
}
}