Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 7th, 2012  |  syntax: None  |  size: 0.25 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public static final boolean isImoValid(String imo) {
  2.         if (imo == null || imo.length() != 7) {
  3.                 return false;
  4.         }
  5.         char[] a = imo.toCharArray();
  6.         int sum = 0;
  7.         for(int i = 0; i < 6; i++) {
  8.                 sum += (a[i]-48)*(a.length-i);
  9.         }
  10.         return sum % 10 == a[6]-48;
  11. }