整数を読み取り、2 と入力値の間のすべての偶数の合計を出力するアプリケーションを設計しようとしています。誰かが最後のビットで私を助けることができますか?!
import java.util.Scanner;
public class IntegerValue {
// main method
public static void main(String[] args) {
// Data fields
int a;
// end
Scanner sc = new Scanner(System.in);
System.out.println("Enter an integer greater than 1");
a = sc.nextInt();
if (a <= 1) {
System.out.println("Input Value must not be less than 2");
}
while (a > 1) {
int sum = 0;
if (a % 2 == 0) {
sum += a;
a = a - 1;
}
System.out.println(sum);
}
}
}