diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..5c50d61 --- /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..7235387 --- /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/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..bf3a4c9 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1583096478615 + + + + + + + + + + \ No newline at end of file diff --git a/Main.java b/Main.java new file mode 100644 index 0000000..bbbdad9 --- /dev/null +++ b/Main.java @@ -0,0 +1,47 @@ +/* + * 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. + */ +package pkg2powern; +/** + * +Ebtsam FATHY +*/ + import java.util.Scanner; + +public class Main { + + /** + * @param args the command line arguments + */ + + + public static void main(String[] args) { + + int N,pow; + int Result=1; + Scanner sc=new Scanner(System.in); + System.out.println("enter the number"); + N=sc.nextInt(); + System.out.println("enter the power"); + pow=sc.nextInt(); + if(N>=0&&pow==0){ + Result=1; + } + if(N==0&&pow>=1){ + Result=0; + } + else{ + int i=1; + while(i<=pow){ + Result=Result*N; + i++; + } + } + System.out.println( N+"^"+pow+"="+Result); + + } + } + + diff --git a/git_assignment_initial4.iml b/git_assignment_initial4.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/git_assignment_initial4.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/git_assignment_initial6.iml b/git_assignment_initial6.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/git_assignment_initial6.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/CircleCircumference.java b/src/CircleCircumference.java new file mode 100644 index 0000000..e9fb7f0 --- /dev/null +++ b/src/CircleCircumference.java @@ -0,0 +1,11 @@ + +public class CircleCircumference implements ISubscriber { + + @Override + public void notifySubscriber(String input) { + // TODO Auto-generated method stub + double r=Double.parseDouble(input); + System.out.println("circle circumference = "+(2*3.14*r)); + } + +} diff --git a/src/LucasSeries.java b/src/LucasSeries.java new file mode 100644 index 0000000..1a968cf --- /dev/null +++ b/src/LucasSeries.java @@ -0,0 +1,17 @@ +public class LucasSeries implements ISubscriber { + public static int lucas_series(int number) { + if (number == 0) + return 2; + if (number == 1) + return 1; + return lucas_series(number - 1) + lucas_series(number - 2); + } + + @Override + public void notifySubscriber(String input) { + int Lenght = Integer.parseInt(input); + System.out.println("Hello, I am really a simple Lucas series and I am notified with " + input); + System.out.println("LUcas Number Is : "+lucas_series(Lenght)); + } + +} diff --git a/src/Main.java b/src/Main.java index 9b8c2b0..de46824 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,17 +1,25 @@ import java.util.Scanner; public class Main { - private static ISubscriber subscribers [] = { - new SimpleSubscriber(), - new ReallySimpleSubscriber(), - }; - public static void main(String[] args) { - Topic mathTopic = new Topic(); - for (ISubscriber sub : subscribers) { - mathTopic.addSubscriber(sub); - } - Scanner sc = new Scanner(System.in); - String input = sc.next(); - mathTopic.dispatchEvent(input); - } + private static ISubscriber subscribers [] = { + new SimpleSubscriber(), + new ReallySimpleSubscriber(), + new SummationSeries(), + new SphereCircumference(), + new LucasSeries(), + new Spherearea(), + new SphereVolume(), + new CircleCircumference() + }; + public static void main(String[] args) { + Topic mathTopic = new Topic(); + for (ISubscriber sub : subscribers) { + mathTopic.addSubscriber(sub); + } + Scanner sc = new Scanner(System.in); + String input = sc.next(); + mathTopic.dispatchEvent(input); + } + + } diff --git a/src/SphereCircumference.java b/src/SphereCircumference.java new file mode 100644 index 0000000..8586e2d --- /dev/null +++ b/src/SphereCircumference.java @@ -0,0 +1,8 @@ + +public class SphereCircumference implements ISubscriber { + + public void notifySubscriber(String input) { + double R = Double.parseDouble(input); + System.out.println("Sphere Circumference is = " + (2*3.14*R)); + +} diff --git a/src/SphereVolume.java b/src/SphereVolume.java new file mode 100644 index 0000000..974905c --- /dev/null +++ b/src/SphereVolume.java @@ -0,0 +1,10 @@ + +public class SphereVolume implements ISubscriber { + @Override + public void notifySubscriber(String input) { + // TODO Auto-generated method stub + double radius = Double.parseDouble ( input ); + double volume =((double)4/3) * Math.PI * Math.pow(radius,3) ; + System.out.println("Sphere Volume is : " + volume); + } +} diff --git a/src/Spherearea.java b/src/Spherearea.java new file mode 100644 index 0000000..178381c --- /dev/null +++ b/src/Spherearea.java @@ -0,0 +1,14 @@ +package myPackage; + +public class Spherearea implements ISubscriber{ + + @Override + public void notifySubscriber(String input) { + double radius = Double.parseDouble(input); + String result = String.valueOf(4*3.14*radius*radius); + System.out.println("Sphere area = " + result); + } +} + + + \ No newline at end of file diff --git a/src/SummationSeries.java b/src/SummationSeries.java new file mode 100644 index 0000000..7a2c38f --- /dev/null +++ b/src/SummationSeries.java @@ -0,0 +1,26 @@ +/* + * 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. + */ +package main; + +import java.util.Scanner; + +/** + * + * @author egypt2 + */ +public class SummationSeries implements ISubscriber{ + @Override + public void notifySubscriber(String input) { + // TODO Auto-generated method stub + int n = Integer.parseInt(input); + System.out.println("Hello, I am really a simple summation series and I am notified with " + input); + + int result = 0; + result = n*(n+1)/2; + System.out.println("The sum of series is " + result); + } + +} \ No newline at end of file