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?

Postby dexik » Wed Jul 11, 2012 6:34 am

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?

 

Re: A simple calculation?

Postby dexik » Wed Jul 11, 2012 6:42 am

NVM. SOLVED IT. HAD TO USE BY INSTEAD OF INTO.
dexik
 
Posts: 28
Joined: Tue Jun 12, 2012 4:30 am
Has thanked: 0 time
Been thanked: 0 time

Re: A simple calculation?

Postby BillyBoyo » Wed Jul 11, 2012 1:40 pm

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: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: A simple calculation?

Postby DFSHDC40 » Thu Jul 12, 2012 3:57 am

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?
User avatar
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?

Postby dexik » Thu Jul 12, 2012 7:14 am

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?

Postby dick scherrer » Thu Jul 12, 2012 8:05 am

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.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: A simple calculation?

Postby dexik » Thu Jul 12, 2012 8:28 pm

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?

Postby ursmdnpavan » Sun Jul 15, 2012 7:08 am

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?

Postby dick scherrer » Sun Jul 15, 2012 7:33 am

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.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post