Advertisement
valiamaximova1

upr3

Mar 19th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ex3 {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         double x1 = Double.parseDouble(scan.nextLine());
  8.         double x2 = Double.parseDouble(scan.nextLine());
  9.         double y1 = Double.parseDouble(scan.nextLine());
  10.         double y2 = Double.parseDouble(scan.nextLine());
  11.  
  12.         double a = Math.abs(x1 - x2);
  13.         double b = Math.abs(y1 - y2);
  14.  
  15.  
  16.         double plosht = a * b;
  17.         double perimeter = 2 * (a + b);
  18.  
  19.         System.out.printf("%.2f%n",plosht );
  20.         System.out.printf("%.2f", perimeter);
  21.  
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement