Advertisement
droidus

Untitled

Nov 5th, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. public class dividesSelf {
  2.  
  3.     static boolean divide(int n) {
  4.  
  5.         int number = n;
  6.  
  7.         if ((number / 100) / number == 0 && (number / 100) != 0) { // 1
  8.             if ((number % 100) / 10 == 0 && ((number % 100)/10) != 0) { // 2
  9.                 if (number % 10 != 0) { // 2
  10.                     return true;
  11.                 }
  12.             }
  13.         } else { // If there is a 0 in the hundreds place, check on the tens and ones place...
  14.             if((number / 100) != 0) { // check the hundreds place to see if there is a 0.
  15.                 if (((number % 100)/10) == 0) { // then check the tens place
  16.                     if (number % 10 != 0) { // then check the ones place
  17.                         return true;
  18.                     }
  19.                 }
  20.             }
  21.             return false; // if other conditions exist, return false
  22.         }
  23.  
  24.         return false;
  25.  
  26.     }
  27.  
  28.     public static void main(String[] args) {
  29.         System.out.println(divide(122));
  30.     }
  31.  
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement