Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -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
65 changes: 49 additions & 16 deletions FindRange.java
Original file line number Diff line number Diff line change
@@ -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);
}
}

}
38 changes: 22 additions & 16 deletions Hailstone.java
Original file line number Diff line number Diff line change
@@ -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<)
}
}
}

49 changes: 31 additions & 18 deletions ProgramHierarchy.java
Original file line number Diff line number Diff line change
@@ -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<SENTINEL; i++) {
n = readInt("?");
println(n);
if (n == SENTINEL){
break;
}
println("End of Program");
}

}
}

98 changes: 66 additions & 32 deletions Pyramid.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,66 @@
/*
* 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() {

placeBricks();

}

public void placeBricks() {

double xMidPoint = getWidth()/2;
double yMidPoint = getHeight()/2;

double xCenterPoint = (xMidPoint - (BRICK_WIDTH/2));
double yCenterPoint = (yMidPoint - (BRICKS_IN_BASE *(BRICK_HEIGHT)/2));

int xIncrementor = 0;

for (int i=0; i<BRICKS_IN_BASE; i++) {
xIncrementor++;
xCenterPoint -= (BRICK_WIDTH/2);

for (int j=0; j < xIncrementor; j++) {

double xNewPosition = j * BRICK_WIDTH;
double yNewPosition = i * BRICK_HEIGHT;

GRect rect = new GRect ((xNewPosition + xCenterPoint), (yNewPosition + yCenterPoint), BRICK_WIDTH, BRICK_HEIGHT);
add(rect);
}
}



}

}


43 changes: 28 additions & 15 deletions PythagoreanTheorem.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
/*
* 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() {


int a = readInt("Input First Side of Triangle - ");
int b = readInt ("Input Second Side of Triangle - ");

double s = 0;
s = Math.sqrt((a*a)+(b*b));

println("a = " + a);
println("b = " + b);
println("s = " + s);
}
}

77 changes: 60 additions & 17 deletions Target.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,60 @@
/*
* 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 {
private double inch = 72;

public void run() {

firstCircle();
secondCircle();
thirdCircle();

}

public void firstCircle(){
double radius = inch * 1;
double x = (getWidth()/2) - radius/2;
double y = ((getHeight()/2) - radius/2);

GOval firstOval = new GOval (x, y, radius, radius);
add(firstOval);
firstOval.setFilled(true);
firstOval.setFillColor(Color.RED);
}

public void secondCircle() {
double radius = inch * 0.65;
double x = ((getWidth())/2) - radius/2;
double y = ((getHeight()/2) - radius/2);

GOval secondOval = new GOval (x, y, radius, radius);
add(secondOval);
secondOval.setFilled(true);
secondOval.setColor(Color.WHITE);
secondOval.setFillColor(Color.WHITE);
}


public void thirdCircle() {
double radius = inch * 0.3;
double x = (getWidth()/2) - radius/2;
double y = ((getHeight()/2) - radius/2);

GOval thirdOval = new GOval (x, y, radius, radius);
add(thirdOval);
thirdOval.setFilled(true);
thirdOval.setFillColor(Color.RED);
}


}