展开全部
100%符合你的要求,其中inputstr1/2随便你怎么弄,可以通62616964757a686964616fe78988e69d8331333335306230过args传入,或者System.in传入,甚至通过文件传入。
import java.math.BigDecimal;
import java.math.RoundingMode;
public class Main {
public static void main(String[] args) {
String inputStr1 = "1 1 3 3";
String inputStr2 = "2 2 4 4";
String[] r1String = inputStr1.split(" ");
Point p1 = new Point(new BigDecimal(r1String[0]),new BigDecimal(r1String[1]));
Point p2 = new Point(new BigDecimal(r1String[2]),new BigDecimal(r1String[3]));
String[] r2String = inputStr2.split(" ");
Point p3 = new Point(new BigDecimal(r2String[0]),new BigDecimal(r2String[1]));
Point p4 = new Point(new BigDecimal(r2String[2]),new BigDecimal(r2String[3]));
Rectangle r1 = new Rectangle(p1, p2);
Rectangle r2 = new Rectangle(p3, p4);
System.out.println("Rectangle 1: " + r1);
System.out.println("Rectangle 2: " + r2);
System.out.println("The crossing area is " + getCrossArea(r1, r2).setScale(2, RoundingMode.HALF_UP));
}
public static BigDecimal getCros