Advertisement
Guest User

funk

a guest
Mar 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1.  
  2. public class Main {
  3.  
  4. public static void main(String[] args) {
  5. Rectangle rect = new Rectangle();
  6. rect.a = 3;
  7. rect.b = 4;
  8. double a = 1;
  9. double pole = 0;
  10. System.out.println (rect.diagonal());
  11. Rectangle[] tab = new Rectangle[100];
  12. for (int i = 0; i < tab.length; i++) {
  13. tab[i].a = a;
  14. tab [i].b = a;
  15. a = a/2;
  16. }
  17. for (int i = 0; i < tab.length; i++) {
  18. pole += tab[i].area();
  19. }
  20. System.out.println (pole);
  21. }
  22.  
  23. }
  24. ------------------------------------------------------------
  25.  
  26. public class Rectangle {
  27. public double a,b;
  28. public double area() {
  29. return a*b;
  30. }
  31. public double perimeter() {
  32. return 2*a+2*b;
  33. }
  34. public double diagonal() {
  35. return Math.sqrt(a*a+b*b);
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement