943,936 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 9313
  • Java RSS
Jun 22nd, 2006
0

Character's Unicode Value

Expand Post »
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):

Java Syntax (Toggle Plain Text)
  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!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pineapple is offline Offline
4 posts
since Jun 2006
Jun 24th, 2006
0

Re: Character's Unicode Value

I think it would be more intutive to create a function such as:
Java Syntax (Toggle Plain Text)
  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().
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Limiting numbers displayed, under a user given value
Next Thread in Java Forum Timeline: vector, put out sorted list





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC