Page 1 of 1

A simple calculation?

PostPosted: Wed Jul 11, 2012 6:34 am
by dexik
This is what I have:

       01 ISBN-NUMBER PIC 9(13).
                01 CHECK-DIGIT PIC 99.

    Procedure division.

            Display 'Enter ISBN Number (13 digits) :'.

            ACCEPT ISBN-NUMBER.

            DIVIDE ISBN-NUMBER INTO 10 GIVING ISBN-NUMBER
                REMAINDER CHECK-DIGIT.

          DISPLAY " ISBN NUMBER AFTER DIVIDE: "
          DISPLAY " CHECK DIGIT IS: "


I enter 9780306406157

ISBN NUMBER AFTER DIVIDE: 0000000000000 (note: there are 13 digits)
CHECK DIGIT IS: 10

Supposed to be 978030640615 and 7.
What am I doing wrong?

Re: A simple calculation?

PostPosted: Wed Jul 11, 2012 6:42 am
by dexik
NVM. SOLVED IT. HAD TO USE BY INSTEAD OF INTO.

Re: A simple calculation?

PostPosted: Wed Jul 11, 2012 1:40 pm
by BillyBoyo
It can be done without the need to divide.

A "modulus 10" check-digit is useless. This is just an exercise, it's not how real ISBN's work is it?

Re: A simple calculation?

PostPosted: Thu Jul 12, 2012 3:57 am
by DFSHDC40
Contact [Insert bank of choice] , you may get a job on their Libor team

Re: A simple calculation?

PostPosted: Thu Jul 12, 2012 7:14 am
by dexik
It is an exercise but it is based on how ISBN-13 numbers are checked in reality. The code of course is longer than what I posted. I can't post the full code until the end of semester. An ISBN-13 number's last digit is a check digit. You add together all odd position digits and multiply by 3. Then add all even position digits. Divide it by 10 and subtract the remainder from 10. The result should equal the check digit.

What's a Libor team? I feel it is some sort of a sarcastic remark.

Re: A simple calculation?

PostPosted: Thu Jul 12, 2012 8:05 am
by dick scherrer
Hello,

What's a Libor team? I feel it is some sort of a sarcastic remark.
Probably . . . We have lots of this here.

Do you have the check-digit code working now - following the rules you posted?

If not, post where you are stuck and that bit of code and someone should be able to help.

Re: A simple calculation?

PostPosted: Thu Jul 12, 2012 8:28 pm
by dexik
Hey Dick, yep everything works fine now. Thank you and thanks everyone

Re: A simple calculation?

PostPosted: Sun Jul 15, 2012 7:08 am
by ursmdnpavan
Hi u written logic correct but where is perform i.e. loop ? it will divide only once right ? if am wrong please correct me..... am just beginner .

Re: A simple calculation?

PostPosted: Sun Jul 15, 2012 7:33 am
by dick scherrer
Hello and welcome to the forum,

We have lots of beginners here :)

It is why this forum was started.

The originally posted code was to use as a basis to ask the divide/remainder question. The actual code for the requirement was not posted.

Dependng on how the complete code is written, there may or may not be a loop.