Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Find the yearly Depreciation. Yearly Depreciation = (Cost - Scap Value) / Years of life.Output file should contain no name no of year and depreciated

Posted By: Ellis Evans     Category: Cobol     Views: 2121

Find the yearly Depreciation.
Yearly Depreciation = (Cost - Scap Value) / Years of life.
Output file should contain no name no of year and depreciated value and cost.

Position Desc.
1 - 3 No
4 - 18 Name
19 - 2 Cost (9(4) V 99).
25 - 29 Scap Value (9(3) V 99).
30 - 31 Years of Life.

Code for Find the yearly Depreciation. Yearly Depreciation = (Cost - Scap Value) / Years of life.Output file should contain no name no of year and depreciated in Cobol

       IDENTIFICATION DIVISION.
       PROGRAM-ID. ASSIGN-5.

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT IN5 ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.
           SELECT OUT5 ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.

       DATA DIVISION.
       FILE SECTION.
       FD IN5
          LABEL RECORDS ARE STANDARD
          VALUE OF FILE-ID IS "IN5.TXT".
       01 IN5-REC.
          05 NO-IN PIC 9(3).
          05 NAME-IN PIC X(15).
          05 COST-IN PIC 9999V99.
          05 SCAP-IN PIC 9(3)V99.
          05 YRS-IN PIC 9999.

       FD OUT5
          LABEL RECORDS ARE STANDARD
          VALUE OF FILE-ID IS "OUT5.TXT".

       01 OUTREC PIC X(80).

       WORKING-STORAGE SECTION.
       77 ARE-THERE-MORE-REC PIC XXX VALUE 'YES'.
       77 WS-DEP PIC 9(4)V99.
       
       01 H1.
          05 STAR PIC X(80) VALUE ALL '*'.
       01 H2.
          05 NUM PIC X(3) VALUE 'NO.'.
          05 FILLER PIC X(5).
          05 NAME PIC X(4) VALUE 'NAME'.
          05 FILLER PIC X(12).
          05 YRS PIC X(3) VALUE 'YRs'.
          05 FILLER PIC X(4).
          05 COST PIC X(4) VALUE 'COST'.
          05 FILLER PIC X(4).
          05 DEP PIC X(12) VALUE 'DEPRITIATION'.
          05 FILLER PIC X(3).
          05 NET PIC X(5) VALUE "NET".
           
       01 OUT5-REC.
          05 NO-OUT PIC 9(3).
          05 FILLER PIC X(3).
          05 NAME-OUT PIC X(15).
          05 FILLER PIC X(1).
          05 YRS-OUT PIC 9999.
          05 FILLER PIC X(3).
          05 COST-OUT PIC 9(4).99.
          05 FILLER PIC X(3).
          05 DEP-OUT PIC 9(4).99.
          05 FILLER PIC X(5).
          05 NET-OUT PIC 9(4).99.

       PROCEDURE DIVISION.
       MAIN-PARA.
           OPEN INPUT IN5
                OUTPUT OUT5.

                WRITE OUTREC FROM H1.
                WRITE OUTREC FROM H2.
                WRITE OUTREC FROM H1.

           READ IN5
                AT END MOVE 'NO' TO ARE-THERE-MORE-REC.
                PERFORM PARA-1 UNTIL ARE-THERE-MORE-REC = 'NO'.
           CLOSE IN5.
           CLOSE OUT5.
           STOP RUN.
       PARA-1.

              MOVE NO-IN TO NO-OUT.
              MOVE NAME-IN TO NAME-OUT.
              MOVE COST-IN TO COST-OUT.
              MOVE YRS-IN TO YRS-OUT.

              COMPUTE WS-DEP = (COST-IN - SCAP-IN) / YRS-IN.
              COMPUTE NET-OUT = COST-IN - WS-DEP.
              MOVE WS-DEP TO DEP-OUT.

              WRITE OUTREC FROM OUT5-REC.
           READ IN5 AT END MOVE 'NO' TO ARE-THERE-MORE-REC.





INput:- 

201Patel Krunal   500000200002003
202Soni Tejas     300000100001988
203Shah Vijay     700000800001987
204Modi Vijay     300000800001988


Output:-

********************************************************************************
NO.     NAME            YRs    COST    DEPRITIATION   NET                       
********************************************************************************
201   Patel Krunal    2003   5000.00   0002.39     4997.61                      
202   Soni Tejas      1988   3000.00   0001.45     2998.55                      
203   Shah Vijay      1987   7000.00   0003.12     6996.88                      
204   Modi Vijay      1988   3000.00   0001.10     2998.90                      
  
Share: 



Ellis Evans
Ellis Evans author of Find the yearly Depreciation. Yearly Depreciation = (Cost - Scap Value) / Years of life.Output file should contain no name no of year and depreciated is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!