Untitled
unknown
plain_text
a year ago
755 B
4
Indexable
Never
public class Rectangle { private int width; private int height; public Rectangle(int width, int height) { this.width = width; this.height = height; } public int getWidth() { return width; } public int getHeight() { return height; } public int calculateArea() { return width * height; } public static void main(String args[]) { int width = 10; int height = 5; Rectangle rectangle = new Rectangle(width, height); System.out.printf("Width: %d\n", rectangle.getWidth()); System.out.printf("Height: %d\n", rectangle.getHeight()); System.out.printf("Area: %d\n", rectangle.calculateArea()); } }