Advertisement
yovkovbpfps

Simple Operation and Calculation 2D Rectangle Area

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