Jump to content

Urgenttttttt Pls..java Help...kastha Ee Code Chusi Results Cheptara...


Recommended Posts

  • Replies 31
  • Created
  • Last Reply

Top Posters In This Topic

  • shivakumar577

    10

  • kskumar

    7

  • ramudu3

    6

  • alpachinao

    3

Popular Days

Top Posters In This Topic

Posted

/*****************************************************************************

 * Write class to validate credit card number using LUHN Formula(Mod 10)

 * Algorithm to validate check digits:

 * 1 - Beginning at the rightmost digit, moving right to left, sum the digits.

 * 2 - For every 2nd digit(from right), double value first, then sum

 * the value of each digit in the doubled number.e.g 6 -> 12, add 1 + 2

 * 3 - Sum for all digits

 * 4 - Take Sum modulo 10, if equal 0, then return true, else false.

 * Ex. "6314", Right->Left digits: 4, (2*1), 3, (2*6), so

 * Sum = (4) + (0+2) + (3) + (1+2) = 12, MOD10(12) = 2, so false

 *****************************************************************************

 */

public class CreditCardCheckDigits {

 

    public CreditCardCheckDigits() {

        // TODO Auto-generated constructor stub

    }

 

    public static boolean checkDigits(String card) {

        // insert required code below

       

    }

 

    public static void lookup(String s) {

        System.out.println("Card Number " + s + " validation is "

                + checkDigits(s));

    }

 

    public static void main(String[] args) {

        lookup("6314");

        lookup("33344555588907");

        lookup("49927398716");

        lookup("8888888555888888");

 

    }

 

}

// Sample output

// Card Number 6314 validation is false

// Card Number 33344555588907 validation is true

// Card Number 49927398716 validation is true

// Card Number 8888888555888888 validation is false

 

here you have to write code for the method

checkdigits() 

 -- must be all integer values

 -- must meet min lenght and max length

Done

Posted

nope creadi card check cheyali  (credur card values mod 10 tho divide ayithy adi donga card) 

here you have to write code for the method

checkdigits() 

 -- must be all integer values

 -- must meet min lenght and max length

Done

 

Posted

Thanks Guys...I really really appreciate for your help.......

 

 

submitted these answers to vendor...

Posted

answers ikkada veyi??? emi pampinchavoooo 

Thanks Guys...I really really appreciate for your help.......

 

 

submitted these answers to vendor...

 

Posted
package com.tt;
 
public class CreditCardCheckDigits {
 
    public CreditCardCheckDigits() {
        // TODO Auto-generated constructor stub
    }
 
    public static boolean checkDigits(String card) {
 
        // insert required code below
    int sum = 0;
        boolean alternate = false;
        for (int i = card.length() - 1; i >= 0; i--)
        {
                int n = Integer.parseInt(card.substring(i, i + 1));
                if (alternate)
                {
                        n *= 2;
                        if (n > 9)
                        {
                                n = (n % 10) + 1;
                        }
                }
                sum += n;
                alternate = !alternate;
        }
        return (sum % 10 == 0);
    }
 
    public static void lookup(String s) {
        System.out.println("Card Number " + s + " validation is "
                + checkDigits(s));
    }
 
    public static void main(String[] args) {
        lookup("6314");
        lookup("33344555588907");
        lookup("49927398716");
        lookup("8888888555888888");
    }
    
   }
   // Sample output
   // Card Number 6314 validation is false
   // Card Number 33344555588907 validation is true
   // Card Number 49927398716 validation is true
   // Card Number 8888888555888888 validation is false
Posted

Thanks Guys...I really really appreciate for your help.......

 

 

submitted these answers to vendor...

ba... 1st post answer chudu...

Posted

answer1

public class CreditCardCheckDigits {

 

    public CreditCardCheckDigits() {

        // TODO Auto-generated constructor stub

    }

 

    public static boolean checkDigits(String card) {

        // insert required code below

        if(card.length()=!0){

    char[] c = card.toCharArray();

    int[] cint = new int[16];

    for(int i=0;i<16;i++){

        if(i%2==1){

            cint[i] = Integer.parseInt(String.valueOf(c[i]))*2;

            if(cint[i] >9)

                cint[i]=1+cint[i]%10;

        }

        else

            cint[i] = Integer.parseInt(String.valueOf(c[i]));

    }

    int sum=0;

    for(int i=0;i<16;i++){

        sum+=cint[i];

    }

    if(sum%10==0)

        result.setText("true");

    else

        result.setText("false");

}else

    result.setText("false");

       

    }

 

    public static void lookup(String s) {

        System.out.println("Card Number " + s + " validation is "

                + checkDigits(s));

    }

 

    public static void main(String[] args) {

        lookup("6314");

        lookup("33344555588907");

        lookup("49927398716");

        lookup("8888888555888888");

 

    }

 

}

 

answer2:

T1, a = 1, b = -1

T1, a = 2, b = -2

T1, a = 3, b = -3

T1, a = 4, b = -4

T1, a = 5, b = -5

T1, a = 6, b = -6

T1, a = 7, b = -7

T1, a = 8, b = -8

T1, a = 9, b = -9

T1, a = 10, b = -10

T1, a = 11, b = -11

T1, a = 12, b = -12

T1, a = 13, b = -13

T1, a = 14, b = -14

T1, a = 15, b = -15

T1, a = 16, b = -16

T1, a = 17, b = -17

T1, a = 18, b = -18

T1, a = 19, b = -19

T1, a = 20, b = -20

T1, a = 21, b = -21

 

infinity..

 

 

 

Posted

answer 2 wrong , its dead lock not infinity loop , paina explanation icha chudu endhuku deadlock vosthadoooo 

 

 

 

first thread

synchronized (a) {

                    synchronized (b) {

                        System.out.println(getName() + ", a = " + a.increment()

                                + ", b = " + b.decrement());

                    }

 

 

 

-- Ikkada first object a meedha synchronized block thesukunnav kadhaa .... and immediate gaa object b meedha kuda synchronized block thesukuntunav

 

 

second thread 

 

 

  synchronized (b) {

                    synchronized (a) {

                        System.out.println(getName() + ", a = " + a.decrement()

                                + ", b = " + b.increment());

 

                    }

 

 

 

-- Ikkada first  object b meedha synchronized block thesukunnav kadhaa .... and immediate gaa object a meedha kuda synchronized block thesukuntunav

 

 

So dead lock vochindi andhukee programm agipothadi .... explanation inka kavali antee cheppu 

 

 



answer1

public class CreditCardCheckDigits {

 

    public CreditCardCheckDigits() {

        // TODO Auto-generated constructor stub

    }

 

    public static boolean checkDigits(String card) {

        // insert required code below

        if(card.length()=!0){

    char[] c = card.toCharArray();

    int[] cint = new int[16];

    for(int i=0;i<16;i++){

        if(i%2==1){

            cint[i] = Integer.parseInt(String.valueOf(c[i]))*2;

            if(cint[i] >9)

                cint[i]=1+cint[i]%10;

        }

        else

            cint[i] = Integer.parseInt(String.valueOf(c[i]));

    }

    int sum=0;

    for(int i=0;i<16;i++){

        sum+=cint[i];

    }

    if(sum%10==0)

        result.setText("true");

    else

        result.setText("false");

}else

    result.setText("false");

       

    }

 

    public static void lookup(String s) {

        System.out.println("Card Number " + s + " validation is "

                + checkDigits(s));

    }

 

    public static void main(String[] args) {

        lookup("6314");

        lookup("33344555588907");

        lookup("49927398716");

        lookup("8888888555888888");

 

    }

 

}

 

answer2:

T1, a = 1, b = -1

T1, a = 2, b = -2

T1, a = 3, b = -3

T1, a = 4, b = -4

T1, a = 5, b = -5

T1, a = 6, b = -6

T1, a = 7, b = -7

T1, a = 8, b = -8

T1, a = 9, b = -9

T1, a = 10, b = -10

T1, a = 11, b = -11

T1, a = 12, b = -12

T1, a = 13, b = -13

T1, a = 14, b = -14

T1, a = 15, b = -15

T1, a = 16, b = -16

T1, a = 17, b = -17

T1, a = 18, b = -18

T1, a = 19, b = -19

T1, a = 20, b = -20

T1, a = 21, b = -21

 

infinity..

 

Posted

submit chesaka chusa mama....vendor gadu force chestunde...submit cheyyi ani...

Posted

/*****************************************************************************

 * Write class to validate credit card number using LUHN Formula(Mod 10)

 * Algorithm to validate check digits:

 * 1 - Beginning at the rightmost digit, moving right to left, sum the digits.

 * 2 - For every 2nd digit(from right), double value first, then sum

 * the value of each digit in the doubled number.e.g 6 -> 12, add 1 + 2

 * 3 - Sum for all digits

 * 4 - Take Sum modulo 10, if equal 0, then return true, else false.

 * Ex. "6314", Right->Left digits: 4, (2*1), 3, (2*6), so

 * Sum = (4) + (0+2) + (3) + (1+2) = 12, MOD10(12) = 2, so false

 *****************************************************************************

 */

public class CreditCardCheckDigits {

 

    public CreditCardCheckDigits() {

        // TODO Auto-generated constructor stub

    }

 

    public static boolean checkDigits(String card) {

        // insert required code below

       

    }

 

    public static void lookup(String s) {

        System.out.println("Card Number " + s + " validation is "

                + checkDigits(s));

    }

 

    public static void main(String[] args) {

        lookup("6314");

        lookup("33344555588907");

        lookup("49927398716");

        lookup("8888888555888888");

 

    }

 

}

// Sample output

// Card Number 6314 validation is false

// Card Number 33344555588907 validation is true

// Card Number 49927398716 validation is true

// Card Number 8888888555888888 validation is false

psuedo code...

 

public boolean checkdigits(s){

String[] splitString = s.split("");

String[] reversepattern = new String[splitstring.length]();

for(int i=s.length,int j=0;i<0;i--,j++){

reversePattern[j] = splitstring[i];

}

//ur logc now...

int sum =0;

for(int count = 0; count>reversepattern.length;count++){

//Convert to num

int num = Integer.parseInt(reversePattern[count]);

if(count%2!=0){

num = num*2;

}

sum = sum + num;

}

 

 

if(sum%10==0){

return true;

}

 

return false;

Posted

vendor ki submit cheyadaniki intha kasta padavu mari interview set ayithy brahmi3.gif

 

submit chesaka chusa mama....vendor gadu force chestunde...submit cheyyi ani...

 

Posted

chala mandi help pondaru neku teledemo

i initiated this topic u know ila negative ga raste evarina help chestaru ani ala commented whether u believe it or not 

Posted

submit chesaka chusa mama....vendor gadu force chestunde...submit cheyyi ani...

lite...vasthe vachindhi lekapothe ledh...

 

don't keep hopes inkoti try chey...mostly itla answers adige vallu desi companies ye...

×
×
  • Create New...