Character's Unicode Value

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2006
Posts: 4
Reputation: pineapple is an unknown quantity at this point 
Solved Threads: 0
pineapple pineapple is offline Offline
Newbie Poster

Character's Unicode Value

 
0
  #1
Jun 22nd, 2006
Hey, I'm a beginner programmer and have been grinding my teeth over this one specific part of my program for hours and have finally admitted to myself that I need help.

Here's the problem:
I have to write an encryption function that is simply the sum of the unicode values of all the letters in a word, multiplied by the product of the unicode values of the FIRST FIVE letters in the word, modulus 1459303249. The words below are what I was given to check that my function was working properly.
  • hello : 1205468819
  • goodbye : 312635099
  • hello27 : 502523728
  • eybdoog : 1200983286
Here's what I've tried so far:
(this I used just to test & make sure the word "hello" would come out to the right number):

  1. long a = ('h' + 'e' + 'l' + 'l' + 'o') * ('h' * 'e' * 'l' * 'l' * 'o')% 1459303249;
It returned a huge, negative number. I have a feeling that I'm mixing things up or otherwise overlooking something simple. Any tips would be greatly appreciated!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Character's Unicode Value

 
0
  #2
Jun 24th, 2006
I think it would be more intutive to create a function such as:
  1. if a
  2. then unicode = 97
  3. end if
  4.  
  5. if b
  6. then unicode = 98
  7. endif

And then to separate your string into chars using the function tochar().
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC