Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package rectangle;
- /**
- *
- * @author Monty
- */
- public class Rectangle {
- private int length, width;
- public Rectangle() {
- length = 2;
- width = 1;
- }
- public void Rectangle(int l, int w) {
- length = l;
- width = w;
- }
- public int perimeter() {
- int perimeter;
- perimeter = 2 * length + 2 * width;
- return(perimeter);
- }
- public int area() {
- int area;
- area = length * width;
- return(area);
- }
- public static void main(String[] args) {
- Rectangle box = new Rectangle();
- System.out.println("Perimeter: " + box.perimeter());
- System.out.println("Area: " + box.area());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment