A simple calculation?

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

A simple calculation?

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?
dexik

Posts: 28
Joined: Tue Jun 12, 2012 4:30 am
Has thanked: 0 time
Been thanked: 0 time

Re: A simple calculation?

dexik

Posts: 28
Joined: Tue Jun 12, 2012 4:30 am
Has thanked: 0 time
Been thanked: 0 time

Re: A simple calculation?

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?
BillyBoyo
Global moderator

Posts: 3738
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 255 times

Re: A simple calculation?

Contact [Insert bank of choice] , you may get a job on their Libor team
If the code hasn't been changed, why is the LKED date today?

DFSHDC40

Posts: 41
Joined: Sat Oct 16, 2010 4:16 pm
Location: IMS.SDFSRESL
Has thanked: 0 time
Been thanked: 0 time

Re: A simple calculation?

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.
dexik

Posts: 28
Joined: Tue Jun 12, 2012 4:30 am
Has thanked: 0 time
Been thanked: 0 time

Re: A simple calculation?

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.
Hope this helps,
d.sch.

dick scherrer
Global moderator

Posts: 6308
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 90 times

Re: A simple calculation?

Hey Dick, yep everything works fine now. Thank you and thanks everyone
dexik

Posts: 28
Joined: Tue Jun 12, 2012 4:30 am
Has thanked: 0 time
Been thanked: 0 time

Re: A simple calculation?

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 .
ursmdnpavan

Posts: 2
Joined: Mon Jun 18, 2012 7:54 am
Has thanked: 0 time
Been thanked: 0 time

Re: A simple calculation?

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.
Hope this helps,
d.sch.

dick scherrer
Global moderator

Posts: 6308
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 90 times