public class DivisibleByThreeAndFive { public static void main(String[] args) { int num = 15; // 判断 num 是否能同时被 3 和 5 整除 if (num % 3 == 0 && num % 5 == 0) { System.out.println(num + " 可以同时被 3 和 5 整除。"); } else { System.out.println(num + " 不能同时被 3 和 5 整除。"); } } }

// 代码注释: // 1. 定义一个类 DivisibleByThreeAndFive。 // 2. 在 main 方法中定义一个整型变量 num,赋值为 15。 // 3. 使用 if 语句判断 num 是否能同时被 3 和 5 整除。 // 4. 如果 num 能同时被 3 和 5 整除,打印输出 num 可以同时被 3 和 5 整除。 // 5. 如果 num 不能同时被 3 和 5 整除,打印输出 num 不能同时被 3 和 5 整除

java判断一个数能否同时被 3 和 5 整除。要求	写出代码注释

原文地址: https://www.cveoy.top/t/topic/cxTd 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录