Im getting this stupid error...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NycCraze88
    New Member
    • Dec 2007
    • 18

    Im getting this stupid error...

    Im wondering what I need to do to fix this problem....here 's the piece of code:

    private static int checkDigits(Str ing choice2) {
    char[] chars = String.valueOf( choice2).toChar Array();
    int check = 0;
    for (int j = 0; j < chars.length; j++)
    check += Integer.parseIn t(String.valueO f((int)pow(10, 14-j)*chars[j]));
    int digit = Integer.parseIn t(String.valueO f(chars[14]));
    return digit;
    }
    }

    Basically, i need to implement the Airline Ticket check digit scheme....and we need to save it in a char array but i need to use the power function and its giving me this error:

    "The method pow(int, int) is undefined for the type AirTicketNums"

    How do I solve this? I tried casting and nothing...
  • NycCraze88
    New Member
    • Dec 2007
    • 18

    #2
    anybody? This error is really pissing me off

    Comment

    • BigDaddyLH
      Recognized Expert Top Contributor
      • Dec 2007
      • 1216

      #3
      What is the specification for that algorithm? pow or no pow it makes no sense.

      Comment

      • NycCraze88
        New Member
        • Dec 2007
        • 18

        #4
        its supposed to use the formula that verifies if the check digit is correct on the inputted number......the formula is:


        14
        Sigma 10^(14-i) X Ai = A15 mod 7
        i=1

        i can post the whole code if you want..

        Comment

        • BigDaddyLH
          Recognized Expert Top Contributor
          • Dec 2007
          • 1216

          #5
          Originally posted by NycCraze88
          its supposed to use the formula that verifies if the check digit is correct on the inputted number......the formula is:


          14
          Sigma 10^(14-i) X Ai = A15 mod 7
          i=1

          i can post the whole code if you want..
          I would avoid doubles -- I'd be concerned about rounding errors. So instead of using pow, I would just do the math and work in longs.

          Comment

          • NycCraze88
            New Member
            • Dec 2007
            • 18

            #6
            I solved the problem. thanks anyway, you guys can delete this thread.

            Comment

            Working...