Program to Find given No is Fancy or not


package javaFixer;

/**
 * Program #6 Program To find give number is Fancy or not. 
 * 
 * Number is Fancy if it satisfy any one of below conditions:
 * 1) 4 Continuous Same digit Ex. 1111,9999 etc.
 * 2) 4 Continuous digit Increment by 1 Ex. 2345,6789 etc.
 * 3) 4 Continuous digit Decrement by 1 Ex. 4321,8765 etc.
 * 
 * @author JavaFixer
 *
 */
public class FancyNumber {
 
 public static void main(String[] args) {
  Long a = 12343215555L;// Given No
  char[] c = a.toString().toCharArray();
  char rN = c[0];
  int rCount = 1;
  char aN = c[0];
  int aCount = 1;
  char dN = c[0];
  int dCount = 1;
  boolean isFancy = false;
  for (int i = 1; i < c.length; i++) {
   
   // Condition 1
   if (rN == c[i]) {
    rCount++;
    if (rCount == 4) {
     System.out.println("Fancy with " + c[i - 3] + c[i - 2] + c[i - 1] + c[i]);
     isFancy = true;
    }
   } else {
    rN = c[i];
    rCount = 1;
   }
   
   // Condition 2
   if ((aN + 1) == c[i]) {
    aCount++;
    aN = c[i];
    if (aCount == 4) {
     System.out.println("Fancy with " + c[i - 3] + c[i - 2] + c[i - 1] + c[i]);
     isFancy = true;
    }
   } else {
    aN = c[i];
    aCount = 1;
   }
   
   // Condition 3
   if ((dN - 1) == c[i]) {
    dCount++;
    dN = c[i];
    if (dCount == 4) {
     System.out.println("Fancy with " + c[i - 3] + c[i - 2] + c[i - 1] + c[i]);
     isFancy = true;
    }
   } else {
    dN = c[i];
    dCount = 1;
   }
  }
  if (isFancy)
   System.out.println("Given No is FANCY");
  else
   System.out.println("Given No is not FANCY");
 }
}


Fancy with 1234
Fancy with 4321
Fancy with 5555
Given No is FANCY