Board index » delphi » Program Help Please

Program Help Please

Can anyone show me how to write a program that computes a check
character according to the following rules:

A. start with a 6 digit number (545965)
B. add the 3 pairs of number it contains (54+59+65)
C. take the sum mod 26 (54+59+65=140) 140 mod 26 = 10
D. return as a check-character, the letter in that position in the
alphabet.  Assume that 0 represents 'A', (so for 10 you would return
K in this example.

Thanks a ton!!!!!

 

Re:Program Help Please


Quote
In article <3172DE4D.4...@hollandhart.com> Chris Montgomery <cmontgom...@hollandhart.com> writes:
>Can anyone show me how to write a program that computes a check
>character according to the following rules:

Homework, is it?  Well, I'll offer a hint or two, but I won't do the work.

Quote
>A. start with a 6 digit number (545965)

This should be fairly simple to do.  Just readln() into a string, use val to
store it into a longint, and if it's invalid, ask to input again.  If it's
good, the compare to make sure it's less than 1,000,000 and greater than
99,999.

Quote
>B. add the 3 pairs of number it contains (54+59+65)

This is the trickiest part.  I'd suggest an array[1..3] of byte, then use a
for loop to read each number.  Remember that the lowest two digits will be
your number mod 100, and that when you've grabbed that, you can div by 100
to move the next two digits into the bottom two places.

Quote
>C. take the sum mod 26 (54+59+65=140) 140 mod 26 = 10

Just sum the elements of your array.

Quote
>D. return as a check-character, the letter in that position in the
>alphabet.  Assume that 0 represents 'A', (so for 10 you would return
>K in this example.

chr() will help you here.

Quote
>Thanks a ton!!!!!

Hope this gives you a good start.

--
Scott F. Earnest           | We now return you to our regularly scheduled
sc...@whiplash.res.cmu.edu | chaos and mayhem. . . .

Other Threads