6&&(num%2==0)){Guessg=newGuess(num);g.getValue();}else{System.out.println("不符合输入规范.." />
class="java" name="code">import java.util.*; public class Welcome { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("输入一个大于6的整数: "); int num = in.nextInt(); if (num > 6 && (num % 2 == 0)) { Guess g = new Guess(num); g.getValue(); } else { System.out.println("不符合输入规范..."); } in.close(); } } class Guess { private int num; public Guess () { this(8); } public Guess (int num) { this.num = num; } private boolean isPrime(int i) { for (int j = 2; j < i - 1; j++) { if (i % j == 0) { return false; } } return true; } public void getValue() { for (int i = 4; i <= this.num; i = i + 2) { for (int a = 2; a <= i / 2; a++) { if (isPrime(a) && isPrime(i - a)) { System.out.println((i + " = " + a + "+" + (i - a))); break; } } } } }
?