Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- Rectangle myRectangle = new Rectangle();
- myRectangle.length = 5.00;
- myRectangle.width = 10.00;
- System.out.println("Action: Invoking getArea() method of the Rectangle");
- System.out.print("Output: ");
- System.out.println(myRectangle.getArea());
- System.out.println();
- myRectangle.length = 3.00;
- myRectangle.width = 4.00;
- System.out.println("Action: Invoking getArea() method of the Rectangle");
- System.out.print("Output: ");
- System.out.println(myRectangle.getArea());
- System.out.println();
- myRectangle.length = 2.50;
- myRectangle.width = 4.50;
- System.out.println("Action: Invoking getArea() method of the Rectangle");
- System.out.print("Output: ");
- System.out.println(myRectangle.getArea());
- }
- }
- class Rectangle {
- public double length;
- public double width;
- public double getArea() {
- return length * width;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment