Exercise: Rectangle Area

Create a program that: Two rectangles with their lower left and upper right corners shown, inside a Cartesian coordinate system.

Your program output should look like this (user input in green):

Point 1:
  x coordinate: 2
  y coordinate: 1
Point 2:
  x coordinate: 4
  y coordinate: 4

Rectangle width: 2, height: 3, area: 6
Width and height are calculated as the absolute difference of the x and y coordinates, respectively. This entails that the order of the points does not matter:
Point 1:
  x coordinate: 4
  y coordinate: 4
Point 2:
  x coordinate: 2
  y coordinate: 1

Rectangle width: 2, height: 3, area: 6
Coordinates might be negative:
Point 1:
  x coordinate: 1
  y coordinate: 1
Point 2:
  x coordinate: -4
  y coordinate: -2

Rectangle width: 5, height: 3, area: 15

Hand in instructions

  1. Make sure your program runs correctly.
  2. Hand in your program by uploading Main.java to Moodle.