Advertisement
galinyotsev123

ProgBasicsJavaBook2.1SimpleCalculations072DRectangleArea

Jan 25th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. double x1 = Double.parseDouble(scanner.nextLine());
  9. double y1 = Double.parseDouble(scanner.nextLine());
  10. double x2 = Double.parseDouble(scanner.nextLine());
  11. double y2 = Double.parseDouble(scanner.nextLine());
  12.  
  13. double width = Math.max(x1, x2) - Math.min(x1, x2);
  14. double height = Math.max(y1, y2) - Math.min(y1, y2);
  15.  
  16. DecimalFormat decimalFormat = new DecimalFormat("#.#########");
  17. System.out.println(decimalFormat.format(width * height));
  18. System.out.println(decimalFormat.format(2 * (width + height)));
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement