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/FindRange.java b/FindRange.java index b662530..c91ccd6 100755 --- a/FindRange.java +++ b/FindRange.java @@ -1,16 +1,49 @@ -/* - * 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.*; + +//Program to find the largest and the smallest numbers + +public class FindRange extends ConsoleProgram { + + private int SENTINEL = 0; + + public void run() { + + println("This Program finds the largest and smallest numbers"); + + int numberInput =1; + int largeNum = 0; + int smallNum = 1000000000; + + + + + while (numberInput!=0){ + + if (numberInput == 0){ + println("You have not entered any valid number"); + } else { + numberInput = readInt("?"); + + + if (numberInput > largeNum) { + largeNum = numberInput; + } + + if ((numberInput < smallNum) && (numberInput != SENTINEL)) { + smallNum = numberInput; + } + } + println ("Largest Number is " + largeNum); + println ("Smallest Number is " + smallNum); + } + } + +} diff --git a/Hailstone.java b/Hailstone.java index 2c7a16e..9a81146 100755 --- a/Hailstone.java +++ b/Hailstone.java @@ -1,16 +1,22 @@ -/* - * 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() { + + + int inputNumber = readInt("?"); + + if (inputNumber != 0) { + //for (int i = 0; i<) + } + } +} + diff --git a/ProgramHierarchy.java b/ProgramHierarchy.java index b666b6d..85fe2d2 100755 --- a/ProgramHierarchy.java +++ b/ProgramHierarchy.java @@ -1,18 +1,31 @@ -/* - * 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() { + + int SENTINEL; + int n; + SENTINEL = readInt("Enter Sentinel Value - "); + + for (int i=0; i