Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- Rectangle rect = new Rectangle();
- rect.a = 3;
- rect.b = 4;
- double a = 1;
- double pole = 0;
- System.out.println (rect.diagonal());
- Rectangle[] tab = new Rectangle[100];
- for (int i = 0; i < tab.length; i++) {
- tab[i].a = a;
- tab [i].b = a;
- a = a/2;
- }
- for (int i = 0; i < tab.length; i++) {
- pole += tab[i].area();
- }
- System.out.println (pole);
- }
- }
- ------------------------------------------------------------
- public class Rectangle {
- public double a,b;
- public double area() {
- return a*b;
- }
- public double perimeter() {
- return 2*a+2*b;
- }
- public double diagonal() {
- return Math.sqrt(a*a+b*b);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement