写一个if语句,判断整数n是否同时满足“被3除余2,被7除余1”的条件,满足时输出“OK”,否则输出“NO”。
import java.util.Scanner;
public class If {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("please enter the number");
int n =in.nextInt();
if((n%3==2)&&(n%7==1))
System.out.println("ok");
else
System.out.println("no");
}
}
转载于:https://blog.51cto.com/828908/657281