Advertisement
YavorGrancharov

RectangleArea

Dec 13th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class RectangleArea {
  3.         public static void main(String[] args) {
  4.  
  5.             Scanner console = new Scanner(System.in);
  6.             double x1 = Double.parseDouble(console.nextLine());
  7.             double y1 = Double.parseDouble(console.nextLine());
  8.             double x2 = Double.parseDouble(console.nextLine());
  9.             double y2 = Double.parseDouble(console.nextLine());
  10.             double a = Math.abs(x1 - x2);
  11.             double h = Math.abs(y1 - y2);
  12.             double area = a * h;
  13.             double perimeter = 2 * (a + h);
  14.  
  15.             System.out.println(area);
  16.             System.out.println(perimeter);
  17.         }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement