200字
2026-11-04课堂任务与课后作业
2026-11-04
2026-11-04

Write a program that determines whether a single integer is even, and uses a loop to count how many even integers are in a group of integers. The framework for the EvenChecker class is provided below.

Part (a)

Complete the isEven method: return true when num is even, otherwise return false. Hint: You may use the remainder operator % to make the determination, for example, num % 2 == 0 means the number is even.

Part (b)

Suppose there are 5 integers: 3, 8, 10, 7, 4. In the main method, complete the following:

1.Use a for loop so that the loop variable i takes on values from 0 to 4 (inclusive), for a total of 5 iterations;

2.Inside the loop body, retrieve the i-th integer based on the value of i (i 0 is 3, i 1 is 8, and so on), and store it in an integer variable num;

3.You must call the isEven method completed in part (a) to determine whether the integer is even. Do not directly write num % 2 == 0;

4.For each integer, output one line in the format: If even, output: even If odd, output: odd 5.After the loop ends, output the total number of even integers in the format: Even count: ;

请提交至https://v.wjx.cn/vm/mCNUNdi.aspx#

2026-11-04课堂任务与课后作业
作者
Administrator
发表于
2026-11-04
License
CC BY-NC-SA 4.0