编辑代码

class Main {
    public static double xToXPower2() {
        return Math.max(Math.random(), Math.random());
    }

	public static void main(String[] args) {
       int count = 0;
       double x = 0.7;
       for(int i = 0; i < 1000000; i++) {
           if(xToXPower2() < x) {
               count++;
           }
       }
       System.out.println((double) count / (double) 1000000);
       System.out.println(Math.pow(x, 2));
	}
}