exercise3_6.java

来自「java程序设计导论(daniel liang著) 所有偶数课后习题答案」· Java 代码 · 共 17 行

JAVA
17
字号
// Exercise3_6.javaimport javax.swing.*;public class Exercise3_6 {    public static void main(String[] args) {        // Prompt the user to enter an integer        int number = Integer.parseInt(JOptionPane.showInputDialog("Enter an integer:"));                if (number % 5 == 0 && number % 6 == 0)            System.out.println(number + " is divisible by both 5 and 6");        else if (number % 5 == 0 ^ number % 6 == 0)            System.out.println(number + " is divisible by both 5 and 6, but not both");        else             System.out.println(number + " is not divisible by either 5 or 6");    }  }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?