Proxy > Gmail Facebook Yahoo!

7. Write"okay" or "not okay" for the results of the test.



import java.lang.String;
import java.util.*;
class checkdig
{
  public static void main(String args[])
  {
    Scanner scan=new Scanner(System.in);
    int i,sum=0,x,a=0;
    String s, y, s2, s1;
    int[] arg = new int[9];
    System.out.println("Enter 9 digit:");
    String dig=scan.nextLine();
    char []c=dig.toCharArray();
    for(i=0;i<9;i++)
    {
      arg[i]=(int)c[i];
    }
    for(i=0;i<9;i++)
    {
      sum=sum+arg[i];
      a=a*10+arg[i];
    }
    s=""+a;
    outer:
      for(i=0;i<9;i++)
    {
      x=sum-arg[i];
      x=x%10;
      y=""+x;
      s1=""+arg[i];
      s2=s.replaceFirst(s1,"");
      int index=s2.indexOf('y');
      if(index!=-1)
      {
        System.out.println("Okay");
        break outer;
      }
      s2=s;
    }
      System.out.println("Not Okay");
  }
}


Responses

0 Respones to "7. Write"okay" or "not okay" for the results of the test."


Send mail to your Friends.  

Expert Feed

 
Return to top of page Copyright © 2011 | My Code Logic Designed by Suneel Kumar