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/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 deleted file mode 100644 index 9b8c2b0..0000000 --- a/src/Main.java +++ /dev/null @@ -1,17 +0,0 @@ -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); - } -} diff --git a/src/SphereCircumference.java b/src/SphereCircumference.java new file mode 100644 index 0000000..8304e05 --- /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)); +} +}