diff --git a/src/CointsVolume.java b/src/CointsVolume.java new file mode 100644 index 0000000..d080e73 --- /dev/null +++ b/src/CointsVolume.java @@ -0,0 +1,28 @@ +import java.util.Scanner; + +class CointsVolume { + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int length1, width1; + System.out.println("Введить довжину"); + length1 = sc.nextInt(); + + System.out.println("Введить ширину"); + width1 = sc.nextInt(); + + + Rectangle rectangle1 = new Rectangle(length1, width1); + Rectangle rectangle2 = new Rectangle(length1, width1); + printRectangleVolume(rectangle1); + printRectangleVolume2(rectangle2); + } + + static void printRectangleVolume(Rectangle rectangle1) { + System.out.println("Площа = " + rectangle1.getVolume()); + } + + static void printRectangleVolume2(Rectangle rectangle2) { + System.out.println("Периметр = " + rectangle2.getVolume2()); + } +} diff --git a/src/Rectangle.java b/src/Rectangle.java new file mode 100644 index 0000000..9c491d9 --- /dev/null +++ b/src/Rectangle.java @@ -0,0 +1,35 @@ +class Rectangle { + int length; + int width; + + Rectangle(int L, int W) { + length = L; + width = W; + } + + int getVolume() { + return length + width; + } + + int getVolume2(){ + return 2 * (length + width); + } + + + + + + + + + + + + + + + + + + +} \ No newline at end of file