第一个自己写的java程序 本人菜鸟
import javax.swing.JOptionPane;/**
* @author Gubowen
*课本习题 P74 3.3
*/
public class test_01_for3_3 {
public static void main (String[] args){
int num=Integer.parseInt(JOptionPane.showInputDialog(null,"请输入一个数","请输入一个数",JOptionPane.QUESTION_MESSAGE));
if (num%5==0 && num%6==0)
System.out.println("Is "+num+" divisible by 5 and 6? true");
else
System.out.println("Is "+num+" divisible by 5 and 6? false");
if (num%5==0 || num%6==0)
System.out.println("Is "+num+" divisible by 5 and 6? true");
else
System.out.println("Is "+num+" divisible by 5 and 6? false");
if (num%5==0 ^ num%6==0)
System.out.println("Is "+num+" divisible by 5 and 6,but not both? true");
else
System.out.println("Is "+num+" divisible by 5 and 6,but not both? false");
}
}