Results 1 to 6 of 6

Thread: Need help on programming...Urgent!

  1. #1
    Senior Member
    Join Date
    Jan 2002
    Location
    South Pole with Penguin
    Posts
    5,270

    Unhappy Need help on programming...Urgent!

    this simple program will read the value from the input file and output to another file.

    let's say the input file has two variables - employee name & department no. and the department number already sorted in ascending order by another program

    myname D10
    yourname D20
    hisname D20
    hername D30
    itsname D30
    thisname D40
    thatname D50

    the output file will list the department no. and no. of employee in that department and display the total no. of employee in the entire company at the bottom

    D10 1
    D20 2
    D30 2
    D40 1
    D50 1

    Total 7

    the program must be written in COBOL, I have attempted to write the program but still got bugs which i can't solve. The source code can be downloaded here and the input file is here

    The bug is inside process-para....help!

    thanks in advance

  2. #2
    Moderator
    Join Date
    Jan 2002
    Location
    Singapore
    Posts
    1,165

    Default

    You need to ask yourself why the value of Old-Territory-No remains constant. It shouldn't.

  3. #3
    Senior Member
    Join Date
    Jan 2002
    Location
    South Pole with Penguin
    Posts
    5,270

    Default

    Originally posted by rty
    You need to ask yourself why the value of Old-Territory-No remains constant. It shouldn't.
    hmm....should put this in the IF ELSE loop???

    Move D-Territory-No to Old-Territory-No.

    what else?

  4. #4
    Member
    Join Date
    Feb 2003
    Location
    Singapore
    Posts
    56

    Default

    you missed the most critical part, a way to keep track of all the departments you've read and the corresponding no. of employees so far...

    a single dimension table will suffice...

    something like this:

    ---01 terr occurs 100 times. <--- set this to the max no. of depts.
    ------05 terr-no pic x(4).
    ------05 terr-ctr pic 9(3).

    as you read the input records, you have to search this table for the newly read territory no (D-Territory-No).

    if found in the table
    ---add 1 to terr-ctr[table-ptr] <--- this tracks the no. of employees
    else
    ---move D-Territory-No to first empty table element
    ---<--- this updates the table for new depts
    ---move D-Territory-No to terr-no[table-ptr] ????
    end-if

    regards and hope this helps.


    ps. i've started doing the pseudo-code for this, i'm just not sure if you will find it of any help.
    Last edited by licorx; 23rd May 2003 at 01:19 AM.

  5. #5
    Senior Member
    Join Date
    Jan 2002
    Location
    South Pole with Penguin
    Posts
    5,270

    Default

    never know can use table...

    anyway, i sovled the bug already

    something like this:

    when it read the d-territory-no, it will first compare with the previous value, which is stored in old-territory-no, if it is the same, then subtotal +1 and d-territory no will move to old-territory-no

    then read the next d-territory-no until it is differnt from the previous value, then it will write the old-territory-no and subtotal to the file, after that it wil reset subtotal to 1 and move the new d-territory-no to old-territory-no

    the whole thing repeat untli EOF
    then the last d-territory-no will be written to file again





    now a new problem...how to make prog A call prog B
    then after B finish, it will continue with prog A?

    A is the main menu actually and B is another program, after B finished, I want it to go back to the main menu again....i know that i cannot call back the prog that called B, what can i do?

    Thanks

  6. #6
    Member
    Join Date
    Feb 2003
    Location
    Singapore
    Posts
    56

    Default

    haha, you've got it man...

    your solution is much better and direct to the point, don't need the additional burden of creating and maintaining a table.

    about the new 'problem'... you already have the solution, use CALL to envoke the second program and when it finishes it will go back to the calling program, much like envoking a procedure or function in the much newer languages.

    hmmm... COBOL, didn't know it's still being taught here...

    regards.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •