Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class RectangleArea2D {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double x1 = Double.parseDouble(scanner.nextLine());
- double y1 = Double.parseDouble(scanner.nextLine());
- double x2 = Double.parseDouble(scanner.nextLine());
- double y2 = Double.parseDouble(scanner.nextLine());
- double x = Math.abs(x1-x2);
- double y = Math.abs(y1-y2);
- double area = x*y;
- double perimeter = (x+y) * 2;
- System.out.println(area);
- System.out.println(perimeter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement