diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..5c98b42
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,2 @@
+# Default ignored files
+/workspace.xml
\ No newline at end of file
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..477e576
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+GitAssignmentObserver
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..84da703
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..3dd0b66
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ 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/GitAssignmentObserver.iml b/GitAssignmentObserver.iml
new file mode 100644
index 0000000..8fe52dd
--- /dev/null
+++ b/GitAssignmentObserver.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/BallVolume.java b/src/BallVolume.java
new file mode 100644
index 0000000..6405a1d
--- /dev/null
+++ b/src/BallVolume.java
@@ -0,0 +1,22 @@
+/**
+ *
+ * @author Eman Ayman Khalaf 20170067
+ */
+import java.util.Scanner;
+
+public class BallVolume implements ISubscriber {
+
+ public BallVolume(){
+
+ }
+
+ @Override
+ public void notifySubscriber(String input) {
+ int radius= Integer.parseInt(input);
+ double pie=3.14285714286;
+ double volume=(4.0/3.0)*pie*(radius*radius*radius); // the volume of ball
+ System.out.println("Volume of the sphere="+volume);
+ }
+
+}
+
diff --git a/src/CircleArea.java b/src/CircleArea.java
new file mode 100644
index 0000000..7f00609
--- /dev/null
+++ b/src/CircleArea.java
@@ -0,0 +1,12 @@
+import java.util.Scanner;
+
+public class CircleArea implements ISubscriber
+{
+ @Override
+ public void notifySubscriber(String input){
+ int r = Integer.parseInt(input);
+ double pi = 3.14, area;
+ area = pi * r * r;
+ System.out.println("Area of circle: "+ area);
+ }
+}
\ No newline at end of file
diff --git a/src/CircleCircumference.java b/src/CircleCircumference.java
new file mode 100644
index 0000000..5d829d1
--- /dev/null
+++ b/src/CircleCircumference.java
@@ -0,0 +1,27 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+
+/**
+ *
+ * @author Nour-Alhoda Khalid
+ */
+public class CircleCircumference implements ISubscriber {
+
+ public CircleCircumference() {
+
+ }
+
+ @Override
+ public void notifySubscriber(String input){
+ double x= Double.parseDouble(input);
+ double y=2*3.14*x;
+ System.out.print("the circumference equals ");
+ System.out.println(y);
+ }
+
+
+}
diff --git a/src/Fibonacci.java b/src/Fibonacci.java
new file mode 100644
index 0000000..2a73cad
--- /dev/null
+++ b/src/Fibonacci.java
@@ -0,0 +1,21 @@
+
+public class Fibonacci implements ISubscriber {
+ @Override
+
+ public void notifySubscriber(String input) {
+ int n = Integer.parseInt(input);
+ int num1 = 0, num2 = 1;
+ System.out.println("How may numbers you want in the sequence:");
+ System.out.print("Fibonacci Series of "+n+" numbers:");
+
+ int i=1;
+ while(i<=n)
+ {
+ System.out.print(num1+" ");
+ int sumOfPrevTwo = num1 + num2;
+ num1 = num2;
+ num2 = sumOfPrevTwo;
+ i++;
+ }
+ }
+}
diff --git a/src/LucasSeries.java b/src/LucasSeries.java
new file mode 100644
index 0000000..8c8d0bb
--- /dev/null
+++ b/src/LucasSeries.java
@@ -0,0 +1,17 @@
+import java.math.BigInteger;
+
+public class LucasSeries {
+
+ private static BigInteger TWO = BigInteger.valueOf(2);
+
+ public static BigInteger fibonacci(BigInteger number) {
+ if (number.equals(BigInteger.ZERO))
+ return TWO;
+
+ if(number.equals(BigInteger.ONE))
+ return BigInteger.ONE;
+
+ return fibonacci(number.subtract(BigInteger.ONE)).add(
+ fibonacci(number.subtract(TWO)));
+ }
+}
\ No newline at end of file
diff --git a/src/Main.java b/src/Main.java
index 9b8c2b0..1116312 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -1,9 +1,23 @@
+
import java.util.Scanner;
public class Main {
- private static ISubscriber subscribers [] = {
+ private static final ISubscriber subscribers [] = {
new SimpleSubscriber(),
+
new ReallySimpleSubscriber(),
+
+ new CircleCircumference(),
+ new SphereVolume(),
+ new SummationSeries(),
+ new MultiplicationSeries(),
+ new LucasSeries()
+
+
+
+
+
+
};
public static void main(String[] args) {
Topic mathTopic = new Topic();
@@ -13,5 +27,10 @@ public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String input = sc.next();
mathTopic.dispatchEvent(input);
+
+ LucasSeries lucasSeries = new LucasSeries();
+ int x = sc.nextInt();
+ lucasSeries.fibonacci(x);
}
}
+
diff --git a/src/MultiplicationSeries.java b/src/MultiplicationSeries.java
new file mode 100644
index 0000000..3f4d1ec
--- /dev/null
+++ b/src/MultiplicationSeries.java
@@ -0,0 +1,14 @@
+import java.math.BigDecimal;
+
+public class MultiplicationSeries implements ISubscriber {
+
+ @Override
+ public void notifySubscriber(String input) {
+ BigDecimal output=new BigDecimal("1");
+ for (int i = Integer.parseInt(input); i > 0; i--) {
+ output=output.multiply(BigDecimal.valueOf(i));
+ }
+ System.out.println("MultiplicationSeries : "+output);
+ }
+
+}
diff --git a/src/SphereVolume.java b/src/SphereVolume.java
new file mode 100644
index 0000000..a2fa0a1
--- /dev/null
+++ b/src/SphereVolume.java
@@ -0,0 +1,17 @@
+import java.lang.Math;
+
+public class SphereVolume implements ISubscriber {
+ private double radius;
+ private double volume;
+
+ public SphereVolume(){radius = 0; volume = 0;}
+
+ @Override
+ public void notifySubscriber(String input) {
+ radius = Double.parseDouble(input);
+ volume = ((double)4 / 3) * 3.14 * Math.pow(radius, 3);
+
+ System.out.print("The SphereVolume = ");
+ System.out.println(volume);
+ }
+}
diff --git a/src/SummationSeries.java b/src/SummationSeries.java
new file mode 100644
index 0000000..8677cd4
--- /dev/null
+++ b/src/SummationSeries.java
@@ -0,0 +1,34 @@
+public class SummationSeries implements ISubscriber
+{
+ public SummationSeries() {}
+
+ int factorial(int t)
+ {
+ int mul = 1;
+
+ while(t > 0)
+ {
+ mul = mul * t;
+
+ t--;
+ }
+ return mul;
+ }
+
+
+
+ @Override
+ public void notifySubscriber(String input)
+ {
+ double y = 0;
+ int x=Integer.parseInt(input);
+
+ SummationSeries mSummationSeries = new SummationSeries();
+ for(int i = 1; i <= x; i++)
+ {
+ y = y + (double)i / (mSummationSeries.factorial(i));
+ }
+ System.out.println("Summation Series: "+y);
+ }
+
+}
\ No newline at end of file
diff --git a/src/TwoPowerN.java b/src/TwoPowerN.java
new file mode 100644
index 0000000..f0bedaf
--- /dev/null
+++ b/src/TwoPowerN.java
@@ -0,0 +1,15 @@
+import java.lang.Math;
+
+public class TwoPowerN implements ISubscriber
+{
+
+ @Override
+ public void notifySubscriber(String input)
+ {
+
+ double n= Double.parseDouble(input);
+
+ System.out.println("2 power " + input + " equals " + Math.pow(2,n));
+ }
+
+}