Friday, October 06, 2006

Prac 3 Question 3



// Question 03 Practical 3
import javax.swing.*;
public class CheckNumber {
public static void main(String[] args) {
String inputStr;
inputStr = JOptionPane.showInputDialog(null,
"Enter Number");
int num = Integer.parseInt(inputStr);
if (num%5== 0 && num%6==0)
JOptionPane.showMessageDialog(null,
num + " is divisible by both 5 and 6");
else if (num%5==0 ^ num%6==0)
JOptionPane.showMessageDialog(null,
num + " is divisible by either 5 or 6, but not both");
else
JOptionPane.showMessageDialog(null,
num + " is NOT divisible by 5 or 6");
} //end main
} //end class

No comments: