summary refs log tree commit diff stats
path: root/java/text/ComplexCalculations.typ
diff options
context:
space:
mode:
Diffstat (limited to 'java/text/ComplexCalculations.typ')
-rw-r--r--java/text/ComplexCalculations.typ31
1 files changed, 31 insertions, 0 deletions
diff --git a/java/text/ComplexCalculations.typ b/java/text/ComplexCalculations.typ
new file mode 100644
index 0000000..b8df211
--- /dev/null
+++ b/java/text/ComplexCalculations.typ
@@ -0,0 +1,31 @@
+#import "/template.typ": *
+#show: A => apply(A)
+#set raw(lang: "java-new")
+#set par(leading: 0.5em)
+
+#assignment(6)[
+  Write a program to add two complex numbers using concept of methods returning objects and methods taking objects as parameters.
+]
+
+#scos("ComplexCalculations")
+
+=== Discussion
+
+#skind[Classes, interfaces and methods used from Java standard library]
+
+- The `double Math.abs(double)` method returns the absolute value of the given `double` value. 
+- `java.util.Scanner` class:
+  - `double nextDouble()`: Scan a `double` value from the the input stream.
+- `java.util.InputMismatchException` is thrown by the methods of `Scanner` class when encountering invalid input.
+
+#skind[Classes and methods implemented in the program]
+
+- The `Complex` class objects represents a a complex number.
+  - Constructor `Complex(double, double)`: Create a complex number object from the provided real and imaginary parts.
+  - `public String toString()` method returns the string representation of the complex number.
+- The `ComplexOperations` class 
+- The `CylinderCalculationsCLI` orchestrates a main program with:
+  - `public static void main(String[])`: Creates a cylinder object with its radius and height given as command-line arguments.
+- The `CylinderCalculationsScan` orchestrates a main program with:
+  - `public static void main(String[])`: Creates a cylinder object with its radius and height taken from user using `java.util.Scanner`.
+#signature()