Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- // Divisible by 5 and 6 or not
- Scanner s = new Scanner(System.in);
- int x;
- System.out.print("Enter an integer: ");
- x = s.nextInt();
- if ((x % 5==0) && (x % 6==0)){
- System.out.print("is "+x+" divisible by 5 and 6? ");
- System.out.print("true");
- }else{
- System.out.print("is "+x+" divisible by 5 and 6? ");
- System.out.print("false");
- }// Divisible by 5 or 6
- if ((x % 5==0) || (x % 6==0)){
- System.out.print("nIs "+x+" divisible by 5 or 6? ");
- System.out.print("true");
- }else{
- System.out.print("Is "+x+" divisible by 5 or 6? ");
- System.out.print("false");
- }// Divisible by 5 or 6,but not both
- if ((x % 5==0) || (x % 6==0)){ here is my problem, i cant figure out the code for "not both" part
- System.out.print("Is "+x+" divisible by 5 or 6, but not both? ");
- System.out.print("true");
- }else{
- System.out.print("Is "+x+" divisible by 5 or 6, but not both? ");
- System.out.print("false");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement