Monty374

Rectangle 1

Nov 2nd, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. package rectangle;
  2.  
  3. /**
  4. *
  5. * @author Monty
  6. */
  7. public class Rectangle {
  8. private int length, width;
  9.  
  10. public Rectangle() {
  11. length = 2;
  12. width = 1;
  13. }
  14.  
  15. public void Rectangle(int l, int w) {
  16. length = l;
  17. width = w;
  18.  
  19. }
  20.  
  21. public int perimeter() {
  22. int perimeter;
  23. perimeter = 2 * length + 2 * width;
  24. return(perimeter);
  25. }
  26.  
  27. public int area() {
  28. int area;
  29. area = length * width;
  30. return(area);
  31. }
  32.  
  33. public static void main(String[] args) {
  34. Rectangle box = new Rectangle();
  35.  
  36. System.out.println("Perimeter: " + box.perimeter());
  37. System.out.println("Area: " + box.area());
  38. }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment