checknumber.java

来自「包括许多JAVA程序」· Java 代码 · 共 29 行

JAVA
29
字号
package checknumber;
import java.util.*;
public class CheckNumber {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		System.out.print("enter a number:");
		int i=scanner.nextInt();		
		if((i%5==0)&&(i%6==0)) 
			System.out.println("i is divisible by both 5 and 6.");
		else System.out.println("error!");
		System.out.print("enter a number:");
		int j=scanner.nextInt();
		if((j%5==0)||(j%6==0))
			System.out.println("j is divisible either 5 or 6.");
		else System.out.println("error!");
		System.out.print("enter a number:");
		int k=scanner.nextInt();
		if(((k%5==0)&&(k%6!=0))||((k%5!=0)&&(k%6==0)))
			System.out.println("k is divisible by 5 or 6,but not both.");
		else System.out.print("error!");

	}

}

⌨️ 快捷键说明

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