| RectangleArea.java | Download |
|---|---|
/*
A program that constructs a Rectangle object and then computes and
prints its area using the getWidth and getHeight methods. (Ex. P2.1)
CSC120A - Berry College - Fall 2006
*/
// import the Rectangle class from the java.awt package
public class RectangleArea {
public static void main( String[] args ) {
// Create a Rectangle extending from the point (50,50) to (100,100)
// Get the width of the rectangle and store it in a variable
// Get the height of the rectangle and store it in a variable
// Compute the area and store it in another variable
// Print out the result
} // end main method
} // end class
|
|
| RectangleArea.java | Download |
| RectangleIntersect.java | Download |
|---|---|
/*
A program that computes the intersection between two Rectangles. (Ex. P2.4)
CSC120A - Berry College - Fall 2006
*/
// import the Rectangle class from the java.awt package
public class RectangleIntersect {
public static void main( String[] args ) {
// create two Rectangle objects
// print them out
// compute the rectangle object representing their intersection
// print out the intersection rectangle
} // end main method
} // end class
|
|
| RectangleIntersect.java | Download |
| RectangleMid.java | Download |
|---|---|
/*
A program that practices some calculations with Rectangle objects.
CSC120A - Berry College - Fall 2006
*/
import java.awt.Rectangle;
public class RectangleMid {
public static void main( String[] args ) {
// create two Rectangle objects
// create a third Rectangle object by computing the:
// - top-left corner halfway between top-left corners of original two
// - width and height the average of the original two
// print out the state of all three objects
} // end main method
} // end class
|
|
| RectangleMid.java | Download |
| Replacer.java | Download |
|---|---|
/*
Write a program that switches the letters "e" and "o" in a string.
Use the replace method repeatedly. Demonstrate the program on the
string "Hello, World!" (Ex. P2.10)
CSC120A - Berry College - Fall 2006
*/
public class Replacer {
public static void main( String[] args ) {
String str = "Hello, World!";
} // end main method
} // end class
|
|
| Replacer.java | Download |