From 218a835abae65740b772488f44f249b43d13b752 Mon Sep 17 00:00:00 2001 From: S Date: Thu, 8 Jun 2017 09:19:58 +0100 Subject: [PATCH 01/14] {"types":"A","runs":1} --- FindRange.java | 32 ++++++++++----------- Hailstone.java | 32 ++++++++++----------- ProgramHierarchy.java | 36 +++++++++++------------ Pyramid.java | 64 ++++++++++++++++++++--------------------- PythagoreanTheorem.java | 30 +++++++++---------- Target.java | 34 +++++++++++----------- 6 files changed, 114 insertions(+), 114 deletions(-) diff --git a/FindRange.java b/FindRange.java index b662530..416b172 100755 --- a/FindRange.java +++ b/FindRange.java @@ -1,16 +1,16 @@ -/* - * File: FindRange.java - * Name: - * Section Leader: - * -------------------- - * This file is the starter file for the FindRange problem. - */ - -import acm.program.*; - -public class FindRange extends ConsoleProgram { - public void run() { - /* You fill this in */ - } -} - +/* + * File: FindRange.java + * Name: + * Section Leader: + * -------------------- + * This file is the starter file for the FindRange problem. + */ + +import acm.program.*; + +public class FindRange extends ConsoleProgram { + public void run() { + /* You fill this in */ + } +} + diff --git a/Hailstone.java b/Hailstone.java index 2c7a16e..17a27fe 100755 --- a/Hailstone.java +++ b/Hailstone.java @@ -1,16 +1,16 @@ -/* - * File: Hailstone.java - * Name: - * Section Leader: - * -------------------- - * This file is the starter file for the Hailstone problem. - */ - -import acm.program.*; - -public class Hailstone extends ConsoleProgram { - public void run() { - /* You fill this in */ - } -} - +/* + * File: Hailstone.java + * Name: + * Section Leader: + * -------------------- + * This file is the starter file for the Hailstone problem. + */ + +import acm.program.*; + +public class Hailstone extends ConsoleProgram { + public void run() { + /* You fill this in */ + } +} + diff --git a/ProgramHierarchy.java b/ProgramHierarchy.java index b666b6d..4d425c7 100755 --- a/ProgramHierarchy.java +++ b/ProgramHierarchy.java @@ -1,18 +1,18 @@ -/* - * File: ProgramHierarchy.java - * Name: - * Section Leader: - * --------------------------- - * This file is the starter file for the ProgramHierarchy problem. - */ - -import acm.graphics.*; -import acm.program.*; -import java.awt.*; - -public class ProgramHierarchy extends GraphicsProgram { - public void run() { - /* You fill this in. */ - } -} - +/* + * File: ProgramHierarchy.java + * Name: + * Section Leader: + * --------------------------- + * This file is the starter file for the ProgramHierarchy problem. + */ + +import acm.graphics.*; +import acm.program.*; +import java.awt.*; + +public class ProgramHierarchy extends GraphicsProgram { + public void run() { + /* You fill this in. */ + } +} + diff --git a/Pyramid.java b/Pyramid.java index cf32252..82c2c2a 100755 --- a/Pyramid.java +++ b/Pyramid.java @@ -1,32 +1,32 @@ -/* - * File: Pyramid.java - * Name: - * Section Leader: - * ------------------ - * This file is the starter file for the Pyramid problem. - * It includes definitions of the constants that match the - * sample run in the assignment, but you should make sure - * that changing these values causes the generated display - * to change accordingly. - */ - -import acm.graphics.*; -import acm.program.*; -import java.awt.*; - -public class Pyramid extends GraphicsProgram { - -/** Width of each brick in pixels */ - private static final int BRICK_WIDTH = 30; - -/** Width of each brick in pixels */ - private static final int BRICK_HEIGHT = 12; - -/** Number of bricks in the base of the pyramid */ - private static final int BRICKS_IN_BASE = 14; - - public void run() { - /* You fill this in. */ - } -} - +/* + * File: Pyramid.java + * Name: + * Section Leader: + * ------------------ + * This file is the starter file for the Pyramid problem. + * It includes definitions of the constants that match the + * sample run in the assignment, but you should make sure + * that changing these values causes the generated display + * to change accordingly. + */ + +import acm.graphics.*; +import acm.program.*; +import java.awt.*; + +public class Pyramid extends GraphicsProgram { + +/** Width of each brick in pixels */ + private static final int BRICK_WIDTH = 30; + +/** Width of each brick in pixels */ + private static final int BRICK_HEIGHT = 12; + +/** Number of bricks in the base of the pyramid */ + private static final int BRICKS_IN_BASE = 14; + + public void run() { + /* You fill this in. */ + } +} + diff --git a/PythagoreanTheorem.java b/PythagoreanTheorem.java index 5b4f30d..f774a30 100755 --- a/PythagoreanTheorem.java +++ b/PythagoreanTheorem.java @@ -1,15 +1,15 @@ -/* - * File: PythagoreanTheorem.java - * Name: - * Section Leader: - * ----------------------------- - * This file is the starter file for the PythagoreanTheorem problem. - */ - -import acm.program.*; - -public class PythagoreanTheorem extends ConsoleProgram { - public void run() { - /* You fill this in */ - } -} +/* + * File: PythagoreanTheorem.java + * Name: + * Section Leader: + * ----------------------------- + * This file is the starter file for the PythagoreanTheorem problem. + */ + +import acm.program.*; + +public class PythagoreanTheorem extends ConsoleProgram { + public void run() { + /* You fill this in */ + } +} diff --git a/Target.java b/Target.java index 44c1f34..5f0e0a1 100755 --- a/Target.java +++ b/Target.java @@ -1,17 +1,17 @@ -/* - * File: Target.java - * Name: - * Section Leader: - * ----------------- - * This file is the starter file for the Target problem. - */ - -import acm.graphics.*; -import acm.program.*; -import java.awt.*; - -public class Target extends GraphicsProgram { - public void run() { - /* You fill this in. */ - } -} +/* + * File: Target.java + * Name: + * Section Leader: + * ----------------- + * This file is the starter file for the Target problem. + */ + +import acm.graphics.*; +import acm.program.*; +import java.awt.*; + +public class Target extends GraphicsProgram { + public void run() { + /* You fill this in. */ + } +} From b1e8ed55c9e226a733c7726b0b54750611f9da5f Mon Sep 17 00:00:00 2001 From: S Date: Thu, 8 Jun 2017 09:29:13 +0100 Subject: [PATCH 02/14] {"types":"C","runs":1} --- FindRange.java | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/FindRange.java b/FindRange.java index 416b172..caa12e5 100755 --- a/FindRange.java +++ b/FindRange.java @@ -9,8 +9,31 @@ import acm.program.*; public class FindRange extends ConsoleProgram { + private static final int SENTINEL = 0; public void run() { - /* You fill this in */ + println("the smalest and the largest values"); + int max=0; + int min=0; + int val; + + while(true ){ + val =readInt (" ?"); + + if (val==SENTINEL){ + break; + } + if (val>max){ + max=val; + } + else if(val Date: Thu, 8 Jun 2017 09:36:37 +0100 Subject: [PATCH 03/14] {"types":"C","runs":7} --- FindRange.java | 1 + 1 file changed, 1 insertion(+) diff --git a/FindRange.java b/FindRange.java index caa12e5..4bfbd91 100755 --- a/FindRange.java +++ b/FindRange.java @@ -7,6 +7,7 @@ */ import acm.program.*; +import java.util.*; public class FindRange extends ConsoleProgram { private static final int SENTINEL = 0; From c6e09ef218f17ed4e1688b9a473817a023fa9513 Mon Sep 17 00:00:00 2001 From: S Date: Thu, 8 Jun 2017 09:37:44 +0100 Subject: [PATCH 04/14] {"types":"C","runs":7} From 8bf7a66f5f8e4db1ec8cd63c78b0682014679f15 Mon Sep 17 00:00:00 2001 From: S Date: Thu, 8 Jun 2017 09:40:01 +0100 Subject: [PATCH 05/14] {"types":"C","runs":8} --- Hailstone.java | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Hailstone.java b/Hailstone.java index 17a27fe..fc3db48 100755 --- a/Hailstone.java +++ b/Hailstone.java @@ -11,6 +11,36 @@ public class Hailstone extends ConsoleProgram { public void run() { /* You fill this in */ + + int n; + int i; + println("Enter a number number "+); + + n =readInt(" Number "); + while (n>1){ + if((n%2)==0){ + n=(n/2); + println("this is even I make halfn/2" +n); + + } + + else if ((n%2)==1){ + + n=((3*n)+1); + + println(" this is ond I make 3*n +1" +n); + + + } + } + } + + + + + + + } } From a86ef121aa9fa5282b4c789ebc2081205d3ec2e9 Mon Sep 17 00:00:00 2001 From: S Date: Thu, 8 Jun 2017 09:40:35 +0100 Subject: [PATCH 06/14] {"types":"C","runs":9} --- Hailstone.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hailstone.java b/Hailstone.java index fc3db48..20cc0ad 100755 --- a/Hailstone.java +++ b/Hailstone.java @@ -14,7 +14,7 @@ public void run() { int n; int i; - println("Enter a number number "+); + println("Enter a number number "+n); n =readInt(" Number "); while (n>1){ From e5bf01ce492081551f3d92e074bb0c733f2eb1be Mon Sep 17 00:00:00 2001 From: S Date: Thu, 8 Jun 2017 09:41:40 +0100 Subject: [PATCH 07/14] {"types":"C","runs":11} --- Hailstone.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Hailstone.java b/Hailstone.java index 20cc0ad..cf491d4 100755 --- a/Hailstone.java +++ b/Hailstone.java @@ -34,13 +34,5 @@ else if ((n%2)==1){ } } } - - - - - - - - } } From ab5a72b37b5268a56f4c1db617f1c0ded5b11c3e Mon Sep 17 00:00:00 2001 From: S Date: Thu, 8 Jun 2017 09:42:01 +0100 Subject: [PATCH 08/14] {"types":"C","runs":12} --- Hailstone.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hailstone.java b/Hailstone.java index cf491d4..7a50c6e 100755 --- a/Hailstone.java +++ b/Hailstone.java @@ -14,7 +14,7 @@ public void run() { int n; int i; - println("Enter a number number "+n); + println("Enter a number number "); n =readInt(" Number "); while (n>1){ From 244efeb2748ce349e0562ce95711f3aa17c676a4 Mon Sep 17 00:00:00 2001 From: S Date: Thu, 8 Jun 2017 09:44:33 +0100 Subject: [PATCH 09/14] {"types":"C","runs":13} --- Pyramid.java | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Pyramid.java b/Pyramid.java index 82c2c2a..423d8af 100755 --- a/Pyramid.java +++ b/Pyramid.java @@ -27,6 +27,29 @@ public class Pyramid extends GraphicsProgram { public void run() { /* You fill this in. */ + + /* You fill this in. */ + double x = (getWidth() - BRICKS_IN_BASE * BRICK_WIDTH) / 2; + double y = getHeight() - BRICK_HEIGHT; + + for (int row = 0; row < BRICKS_IN_BASE; row++){ + drawRow(x, y, (BRICKS_IN_BASE - row)); + y -= BRICK_HEIGHT; + x += BRICK_WIDTH / 2; + } + } + + private void drawRow(double x, double y, int bricks){ + for (int i = 0; i < bricks; i++){ + drawBrick((x + i * BRICK_WIDTH), y); + } + } + private void drawBrick(double x, double y){ + GRect rect = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT); + add(rect); + } + + } -} + From abf16ddcdacdb7738a4b077b22fbf8bc7e8df227 Mon Sep 17 00:00:00 2001 From: S Date: Thu, 8 Jun 2017 09:47:53 +0100 Subject: [PATCH 10/14] {"types":"C","runs":18} --- Target.java | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Target.java b/Target.java index 5f0e0a1..88d1296 100755 --- a/Target.java +++ b/Target.java @@ -13,5 +13,36 @@ public class Target extends GraphicsProgram { public void run() { /* You fill this in. */ + + drawLargeRedOval(); + drawWhiteOval(); + drawSmallRedOval(); + } + + /* You fill this in. */ + public void drawLargeRedOval() { + GOval oval1= new GOval(64, 64, 72, 72); + oval1.setFilled(true); + oval1.setColor(Color.red); + add (oval1); + } + public void drawWhiteOval(){ + GOval oval2= new GOval(76.6, 76.6, 46.8, 46.8); + oval2.setFilled(true); + oval2.setColor(Color.white); + add (oval2); + } + public void drawSmallRedOval() { + GOval oval3= new GOval(89.2, 89.2, 21.6, 21.6); + oval3.setFilled(true); + oval3.setColor(Color.red); + add (oval3); + } + } + + + + + } } From 7277b391c9ba0766b4ff6b81c49e168257a16901 Mon Sep 17 00:00:00 2001 From: S Date: Thu, 8 Jun 2017 09:48:03 +0100 Subject: [PATCH 11/14] {"types":"C","runs":18} --- Target.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Target.java b/Target.java index 88d1296..560f411 100755 --- a/Target.java +++ b/Target.java @@ -44,5 +44,5 @@ public void drawSmallRedOval() { - } -} + + From eb7b84b948a98968b21aeb0904cac9095b5e6e4a Mon Sep 17 00:00:00 2001 From: S Date: Thu, 8 Jun 2017 09:52:21 +0100 Subject: [PATCH 12/14] {"types":"C","runs":20} --- PythagoreanTheorem.java | 52 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/PythagoreanTheorem.java b/PythagoreanTheorem.java index f774a30..21295a0 100755 --- a/PythagoreanTheorem.java +++ b/PythagoreanTheorem.java @@ -7,9 +7,55 @@ */ import acm.program.*; +import java.util.Scanner; + public class PythagoreanTheorem extends ConsoleProgram { - public void run() { - /* You fill this in */ + + public static void main(String[] args){ + + double legA, legB; + + + //Declare a String object to store the uer's name, + + + //Create a Scanner object for reading in the user's input + Scanner input= new Scanner(System.in); + + + //Prompt the user for the lengths of the legs, + //and store those two pieces of information in legA and legB. + System.out.println("Please enter the length of the " + + "first leg of the right triangle:"); + legA = input.nextDouble(); + + System.out.println("Please enter the length of the " + + "second leg of the right triangle:"); + legB = input.nextDouble(); + + //System.out.println(legA + " " + legB); + + //Declare variables for the quantities to be calculated. + double hypotenuse; + + //Calculate the hypotenuse using the Pythagorean Theorem: + //a^2 + b^2 = c^2 + //c = Math.sqrt(a^2 + b^2) + hypotenuse = Math.sqrt((legA*legA) + (legB*legB)); + + //Report the results for hypotenuse. + System.out.println(); + System.out.println("the hypotenuse of your " + hypotenuse); + + + } } -} + + + + + + + + \ No newline at end of file From ea919e4b8f89686a19b289c64cccf55803a51efe Mon Sep 17 00:00:00 2001 From: S Date: Thu, 8 Jun 2017 09:54:58 +0100 Subject: [PATCH 13/14] {"types":"C","runs":21} --- ProgramHierarchy.java | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/ProgramHierarchy.java b/ProgramHierarchy.java index 4d425c7..6e4ecf8 100755 --- a/ProgramHierarchy.java +++ b/ProgramHierarchy.java @@ -11,8 +11,34 @@ import java.awt.*; public class ProgramHierarchy extends GraphicsProgram { - public void run() { - /* You fill this in. */ + + private static final int HEIGHT = 50; + private static final int WIDTH = 150; + public void run() { + int x; + int y; + x = (getWidth() - WIDTH) / 2; + y = (getHeight() - HEIGHT) /2; + GRect Rect = new GRect(x, y, WIDTH, HEIGHT); + add(Rect); + GLabel label1 = new GLabel("Program", (x + 50), (y + 30)); + add(label1); + GLine Line1 = new GLine((x + 75), (y+50), (x+75), (y+100)); + add(Line1); + GRect Rect2 = new GRect(x, (y+100), WIDTH, HEIGHT); + add(Rect2); + GLabel label2 = new GLabel("ConsoleProgram", (x + 30), (y + 130)); + add(label2); + GLine Line2 = new GLine((x - 100), (y + 100), (x + 75), (y + 50)); + add(Line2); + GRect Rect3 = new GRect((x - 175), (y + 100), WIDTH, HEIGHT); + add(Rect3); + GLabel label3 = new GLabel("GraphicProgram", (x - 145), (y + 130)); + add(label3); + GRect Rect4 = new GRect((x+175), (y+100), WIDTH, HEIGHT); + add(Rect4); + GLabel label4 = new GLabel("DialogProgram", (x + 210), (y + 130)); + add(label4); + } } -} From aeae166c091975e79f92163206fd2fa7e548fd0a Mon Sep 17 00:00:00 2001 From: rasheey97 Date: Thu, 8 Jun 2017 10:00:30 +0100 Subject: [PATCH 14/14] THIS IS MY SECOND ASSIGNMENT2 --- .settings/org.eclipse.jdt.core.prefs | 12 ++++++++++++ java.policy.applet | 7 +++++++ 2 files changed, 19 insertions(+) create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 java.policy.applet diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ef8a789 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/java.policy.applet b/java.policy.applet new file mode 100644 index 0000000..ba9f51d --- /dev/null +++ b/java.policy.applet @@ -0,0 +1,7 @@ +/* AUTOMATICALLY GENERATED ON Tue Apr 16 17:20:59 EDT 2002*/ +/* DO NOT EDIT */ + +grant { + permission java.security.AllPermission; +}; +