Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
fc5dda8
Update Main.java
nourelsakhey Feb 29, 2020
9000119
20170320
nourelsakhey Feb 29, 2020
318afb8
Thoria hamdy 20170082 SphereVolume
ThoriaHamdy99 Feb 29, 2020
9c2bf54
Delete SphereVolume.java
nourelsakhey Mar 1, 2020
d664044
Update Main.java
nourelsakhey Mar 1, 2020
60ea656
Delete CircleCircumference.java
nourelsakhey Mar 1, 2020
ea6a32b
Delete SphereVolume.java
nourelsakhey Mar 1, 2020
1f40deb
Update Main.java
nourelsakhey Mar 1, 2020
111804f
Mostafa Mohamed 20140272 SummationSeries
YahiaNabil Mar 1, 2020
e0f1058
Merge branch 'master' into MostafaMohamed20140272SummationSeries
Mostafa2369 Mar 1, 2020
e9e48d6
Merge pull request #1 from nourelsakhey/MostafaMohamed20140272Summati…
Mostafa2369 Mar 1, 2020
3805911
Merge branch '20170320-CircleCircumference'
nourelsakhey Mar 1, 2020
d1562b2
Add files via upload
nourelsakhey Mar 1, 2020
79837a3
Mostafa Mohamed 20140272 SummationSeries
Mostafa2369 Mar 1, 2020
f5fe720
Merge pull request #2 from nourelsakhey/MostafaMohamed20140272Summati…
Mostafa2369 Mar 1, 2020
112f8c4
adding MultiplicationSeries
abdelrahman2099 Mar 1, 2020
de378e8
Circle Area 20150262
moataz1996 Mar 2, 2020
f08e96a
Merge pull request #3 from nourelsakhey/branch20150262
moataz1996 Mar 2, 2020
25dc855
20160168-2PowerN
AmrDodchy Mar 2, 2020
618b7ee
2PowerN Added
AmrDodchy Mar 2, 2020
d61d153
Fibonacci-20160198
Mohamedhusseind Mar 2, 2020
93c8dfc
MultiplicationSeries 20170152
abdelrahman2099 Mar 1, 2020
f3c8405
Circle Area 20150262
moataz1996 Mar 2, 2020
74adee4
Merge pull request #5 from nourelsakhey/20120428/SphereCircumference
nehal2012 Mar 2, 2020
96b1b7c
Merge branch 'master' into 20160168-2PowerN
AmrDodchy Mar 2, 2020
4a17571
Merge pull request #4 from nourelsakhey/20160168-2PowerN
AmrDodchy Mar 2, 2020
c1cdaaa
Implemented update
Mohamedhusseind Mar 2, 2020
c29ccbd
Merge pull request #6 from nourelsakhey/Fibonacci
AmrDodchy Mar 2, 2020
278a595
Fibonacci editing
Mohamedhusseind Mar 2, 2020
a2f7163
emanayman20170067ballvolume
emanayman657 Mar 2, 2020
96d110f
Merge branch 'fibonacci'
abdelrahman2099 Mar 2, 2020
11ac419
Merge branch '20170067branch'
abdelrahman2099 Mar 2, 2020
3c01b8a
20170082_SphereVolume
ThoriaHamdy99 Mar 3, 2020
6aa3681
Merge pull request #7 from nourelsakhey/20170082_sphereVolume
ThoriaHamdy99 Mar 3, 2020
dba6b22
MultiplicationSeries 20170152
abdelrahman2099 Mar 3, 2020
7c48818
Merge pull request #8 from nourelsakhey/20170152
abdelrahman2099 Mar 3, 2020
a91599f
adding Fibonacci in main
abdelrahman2099 Mar 3, 2020
0d51a60
new
emanayman657 Mar 3, 2020
2539cff
Merge pull request #9 from nourelsakhey/20170067branch
emanayman657 Mar 3, 2020
1ab391b
Revert "20120428/sphere circumference"
nehal2012 Mar 3, 2020
d784810
Merge pull request #10 from nourelsakhey/revert-5-20120428/SphereCirc…
nehal2012 Mar 3, 2020
b774fc6
Fibonacci_function
Mohamedhusseind Mar 3, 2020
85b9c11
fibonacci
MajokChany Mar 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions GitAssignmentObserver.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/bin" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
</component>
</module>
22 changes: 22 additions & 0 deletions src/BallVolume.java
Original file line number Diff line number Diff line change
@@ -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);
}

}

12 changes: 12 additions & 0 deletions src/CircleArea.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
27 changes: 27 additions & 0 deletions src/CircleCircumference.java
Original file line number Diff line number Diff line change
@@ -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);
}


}
21 changes: 21 additions & 0 deletions src/Fibonacci.java
Original file line number Diff line number Diff line change
@@ -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++;
}
}
}
17 changes: 17 additions & 0 deletions src/LucasSeries.java
Original file line number Diff line number Diff line change
@@ -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)));
}
}
21 changes: 20 additions & 1 deletion src/Main.java
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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);
}
}

14 changes: 14 additions & 0 deletions src/MultiplicationSeries.java
Original file line number Diff line number Diff line change
@@ -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);
}

}
17 changes: 17 additions & 0 deletions src/SphereVolume.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
34 changes: 34 additions & 0 deletions src/SummationSeries.java
Original file line number Diff line number Diff line change
@@ -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);
}

}
15 changes: 15 additions & 0 deletions src/TwoPowerN.java
Original file line number Diff line number Diff line change
@@ -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));
}

}