diff --git a/Semester 2/Assignments/MP3_CalebFontenot.html b/Semester 2/Assignments/MP3_CalebFontenot.html new file mode 100644 index 0000000..fb1ad46 --- /dev/null +++ b/Semester 2/Assignments/MP3_CalebFontenot.html @@ -0,0 +1,175 @@ + + + +MP3_CalebFontenot.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/MP3_CalebFontenot.java
+
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
+ */
+package mp3_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class MP3_CalebFontenot {
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args)
+    {
+        Scanner input = new Scanner(System.in);
+        System.out.print("Enter the first complex number: ");
+        double a = input.nextDouble();
+        double b = input.nextDouble();
+        Complex c1 = new Complex(a, b);
+        System.out.print("Enter the second complex number: ");
+        double c = input.nextDouble();
+        double d = input.nextDouble();
+        Complex c2 = new Complex(c, d);
+        System.out.println("(" + c1 + ")" + " + " + "(" + c2 + ")" + " = "
+                + c1.add(c2));
+        System.out.println("(" + c1 + ")" + " - " + "(" + c2 + ")" + " = "
+                + c1.subtract(c2));
+        System.out.println("(" + c1 + ")" + " * " + "(" + c2 + ")" + " = "
+                + c1.multiply(c2));
+        System.out.println("(" + c1 + ")" + " / " + "(" + c2 + ")" + " = "
+                + c1.divide(c2));
+        System.out.println("|" + c1 + "| = " + c1.abs());
+        Complex c3 = (Complex) c1.clone();
+        System.out.println(c1 == c3);
+        System.out.println(c3.getRealPart());
+        System.out.println(c3.getImaginaryPart());
+    }
+
+
+
+}
+
+class Complex {
+
+    private double a;
+    private double b;
+    private final double i = Math.sqrt(-1);
+
+    public Complex()
+    {
+        this.a = 0;
+    }
+
+    public Complex(double a)
+    {
+        this.a = a;
+        this.b = 0;
+    }
+
+    public Complex(double a, double b)
+    {
+        this.a = a;
+        this.b = b;
+    }
+
+    public Complex add(double c, double d)
+    {
+        return new Complex(this.a + c, this.b + d);
+    }
+
+    public Complex add(Complex obj)
+    {
+        return new Complex(this.a + obj.a, this.b + obj.b);
+    }
+
+    public Complex subtract(double c, double d)
+    {
+        return new Complex(this.a - c, this.b - d);
+    }
+    public Complex subtract(Complex obj)
+    {
+        return new Complex(this.a - obj.a, this.b - obj.b);
+    }
+    
+    public Complex multiply(double c, double d)
+    {
+       double r = this.a * c - this.b * d;
+        double i = this.a * d + this.b * c;
+        return new Complex(r, i);
+    }
+    public Complex multiply(Complex obj) {
+        double r = this.a * obj.a - this.b * obj.b;
+        double i = this.a * obj.b + this.b * obj.a;
+        return new Complex(r, i);
+    }
+    
+    public Complex divide(double c, double d)
+    {
+         double denominator = (c * c) + (this.b * this.b);
+        double aNum = (this.a * c) + (this.b * this.b);
+        double iNum = (this.b * c) - (this.a * d);
+        double realResult = aNum / denominator;
+        double imaginaryResult = iNum / denominator;
+        return new Complex(realResult, imaginaryResult);
+    }
+    public Complex divide(Complex obj)
+    {
+        double denominator = (obj.a * obj.a) + (this.b * this.b);
+        double aNum = (this.a * obj.a) + (this.b * obj.b);
+        double iNum = (this.b * obj.a) - (this.a * obj.b);
+        double realResult = aNum / denominator;
+        double imaginaryResult = iNum / denominator;
+        return new Complex(realResult, imaginaryResult);
+    }
+    
+    
+    @Override
+    public String toString()
+    {
+        return  a  + " + " +  b + "i";
+    }
+    
+    public Complex clone() {
+        Complex obj = new Complex(this.a, this.b);
+        return obj;
+    }
+    
+    public double abs() {
+        return Math.abs(this.a + this.b);
+    }
+    
+    public double getRealPart() {
+        return this.a;
+    }
+    public double getImaginaryPart() {
+        return this.b;
+    }
+    
+}
+
+
+ diff --git a/Semester 2/Assignments/MP3_CalebFontenot/nbproject/build-impl.xml b/Semester 2/Assignments/MP3_CalebFontenot/nbproject/build-impl.xml index f41b929..e3a0543 100644 --- a/Semester 2/Assignments/MP3_CalebFontenot/nbproject/build-impl.xml +++ b/Semester 2/Assignments/MP3_CalebFontenot/nbproject/build-impl.xml @@ -119,43 +119,7 @@ is divided into following sections: - - - - - - - - - - - - - - - - - - - - - - - - - - Must set platform.home - Must set platform.bootcp - Must set platform.java - Must set platform.javac - - The J2SE Platform is not correctly set up. - Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. - Either open the project in the IDE and setup the Platform with the same name or add it manually. - For example like this: - ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) - or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) - + @@ -278,6 +242,20 @@ is divided into following sections: + + + + + + + + + + + + + + @@ -365,7 +343,7 @@ is divided into following sections: - + @@ -416,7 +394,7 @@ is divided into following sections: - + @@ -458,7 +436,7 @@ is divided into following sections: - + @@ -537,7 +515,7 @@ is divided into following sections: - + @@ -565,7 +543,7 @@ is divided into following sections: - + @@ -641,7 +619,7 @@ is divided into following sections: - + @@ -872,9 +850,6 @@ is divided into following sections: - - - @@ -924,7 +899,7 @@ is divided into following sections: - + @@ -958,7 +933,7 @@ is divided into following sections: - + @@ -990,7 +965,7 @@ is divided into following sections: - + @@ -1224,7 +1199,7 @@ is divided into following sections: To run this application from the command line without Ant, try: - ${platform.java} -jar "${dist.jar.resolved}" + java -jar "${dist.jar.resolved}" @@ -1326,8 +1301,8 @@ is divided into following sections: - - + + @@ -1520,19 +1495,16 @@ is divided into following sections: - - - - + - + - + diff --git a/Semester 2/Assignments/MP3_CalebFontenot/nbproject/genfiles.properties b/Semester 2/Assignments/MP3_CalebFontenot/nbproject/genfiles.properties index 58a3018..f6d5116 100644 --- a/Semester 2/Assignments/MP3_CalebFontenot/nbproject/genfiles.properties +++ b/Semester 2/Assignments/MP3_CalebFontenot/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=fa6a89f2 +build.xml.data.CRC32=af984b5c build.xml.script.CRC32=3d30e549 build.xml.stylesheet.CRC32=f85dc8f2@1.105.0.48 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=fa6a89f2 -nbproject/build-impl.xml.script.CRC32=12cf189c +nbproject/build-impl.xml.data.CRC32=af984b5c +nbproject/build-impl.xml.script.CRC32=19fda9dc nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.105.0.48 diff --git a/Semester 2/Assignments/MP3_CalebFontenot/nbproject/project.properties b/Semester 2/Assignments/MP3_CalebFontenot/nbproject/project.properties index 9f69764..1e2e4ff 100644 --- a/Semester 2/Assignments/MP3_CalebFontenot/nbproject/project.properties +++ b/Semester 2/Assignments/MP3_CalebFontenot/nbproject/project.properties @@ -36,7 +36,9 @@ dist.jlink.output=${dist.jlink.dir}/MP3_CalebFontenot endorsed.classpath= excludes= includes=** +jar.archive.disabled=${jnlp.enabled} jar.compress=false +jar.index=${jnlp.enabled} javac.classpath= # Space-separated list of extra javac options javac.compilerargs= @@ -73,11 +75,28 @@ jlink.additionalmodules= jlink.additionalparam= jlink.launcher=true jlink.launcher.name=MP3_CalebFontenot +jnlp.codebase.type=no.codebase +jnlp.descriptor=application +jnlp.enabled=false +jnlp.mixed.code=default +jnlp.offline-allowed=false +jnlp.signed=false +jnlp.signing= +jnlp.signing.alias= +jnlp.signing.keystore= main.class=mp3_calebfontenot.MP3_CalebFontenot +# Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found. +manifest.custom.application.library.allowable.codebase= +# Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts. +manifest.custom.caller.allowable.codebase= +# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed +manifest.custom.codebase= +# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) +manifest.custom.permissions= manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false -platform.active=JDK_17 +platform.active=default_platform run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} diff --git a/Semester 2/Assignments/MP3_CalebFontenot/nbproject/project.xml b/Semester 2/Assignments/MP3_CalebFontenot/nbproject/project.xml index 17b9f40..755c36f 100644 --- a/Semester 2/Assignments/MP3_CalebFontenot/nbproject/project.xml +++ b/Semester 2/Assignments/MP3_CalebFontenot/nbproject/project.xml @@ -4,7 +4,6 @@ MP3_CalebFontenot - diff --git a/Semester 2/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/MP3_CalebFontenot.java b/Semester 2/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/MP3_CalebFontenot.java index fd14ec9..fa1c8ec 100644 --- a/Semester 2/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/MP3_CalebFontenot.java +++ b/Semester 2/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/MP3_CalebFontenot.java @@ -101,14 +101,21 @@ class Complex { public Complex divide(double c, double d) { - return new Complex(this.a / c, this.a - d); + double denominator = (c * c) + (this.b * this.b); + double aNum = (this.a * c) + (this.b * this.b); + double iNum = (this.b * c) - (this.a * d); + double realResult = aNum / denominator; + double imaginaryResult = iNum / denominator; + return new Complex(realResult, imaginaryResult); } public Complex divide(Complex obj) { - double denominator = this.a * this.a + this.b * this.b; - double r = (this.a * obj.b + this.a * obj.b) / denominator; - double i = (this.b * obj.b - this.a * obj.b) / denominator; - return new Complex(r, i); + double denominator = (obj.a * obj.a) + (this.b * this.b); + double aNum = (this.a * obj.a) + (this.b * obj.b); + double iNum = (this.b * obj.a) - (this.a * obj.b); + double realResult = aNum / denominator; + double imaginaryResult = iNum / denominator; + return new Complex(realResult, imaginaryResult); } @@ -124,7 +131,7 @@ class Complex { } public double abs() { - return Math.abs(this. a + this.b); + return Math.abs(this.a + this.b); } public double getRealPart() { diff --git a/Semester 2/ZIPs/MP3_CalebFontenot.zip b/Semester 2/ZIPs/MP3_CalebFontenot.zip new file mode 100644 index 0000000..7a4259b Binary files /dev/null and b/Semester 2/ZIPs/MP3_CalebFontenot.zip differ