galinyotsev123

ProgBasics02Simple-Operations-Y03-2DrectangleArea

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