Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program for, asks user to input data and stores it in to the file

Posted By: Meryl Schmidt     Category: Cobol     Views: 3326

Write a program for, asks user to input data and stores it in to the file.

Code for Program for, asks user to input data and stores it in to the file in Cobol

    IDENTIFICATION DIVISION.
     PROGRAM-ID. fileid1.

    ENVIRONMENT DIVISION.

     CONFIGURATION SECTION.
      SOURCE-COMPUTER. IBM-PC.
      OBJECT-COMPUTER. IBM-PC.

     INPUT-OUTPUT SECTION.
      FILE-CONTROL.
       
       SELECT file-write ASSIGN TO DISK
       ORGANIZATION IS LINE SEQUENTIAL.

    DATA DIVISION.
     FILE SECTION.
      FD file-write
       VALUE OF FILE-ID IS "filedemo.ctx".
       01 frec.
        02 frno PIC 99.
        02 fname1 PIC X(20).
        02 fm1 PIC 999.
        02 fm2 PIC 999.
        02 fm3 PIC 999.
        02 ftotal PIC 999.

     WORKING-STORAGE SECTION.
      01 rec.
        02 rno PIC 99.
        02 name1 PIC X(20).
        02 m1 PIC 999.
        02 m2 PIC 999.
        02 m3 PIC 999.
        02 total PIC 999.
      77 wish PIC X VALUE 'Y'.

     LINKAGE SECTION.
     REPORT SECTION.

    PROCEDURE DIVISION.
     begin.

        OPEN OUTPUT file-write.

        PERFORM UNTIL wish = 'N' OR 'n'
            DISPLAY "Enter Roll No :-> " WITH NO ADVANCING
            ACCEPT rno

            DISPLAY "Enter Name    :-> " WITH NO ADVANCING
            ACCEPT name1

            DISPLAY "Enter Marks1  :-> " WITH NO ADVANCING
            ACCEPT m1

            DISPLAY "Enter Marks2  :-> " WITH NO ADVANCING
            ACCEPT m2

            DISPLAY "Enter Marks3  :-> " WITH NO ADVANCING
            ACCEPT m3

            COMPUTE total = m1 + m2 + m3

            MOVE rec TO frec
            WRITE frec

            DISPLAY "Would you like 2 continue??(Y/N):-> "
            ACCEPT wish

        END-PERFORM.

        CLOSE file-write.
        STOP RUN.

******
OUTPUT
******

ENTER ROLL NO :-> 01
ENTER NAME    :-> VD
ENTER MARKS1  :-> 50
ENTER MARKS1  :-> 60
ENTER MARKS1  :-> 70
Would you like 2 continue??(Y/N):-> Y

ENTER ROLL NO :-> 02
ENTER NAME    :-> AMIT
ENTER MARKS1  :-> 70
ENTER MARKS1  :-> 50
ENTER MARKS1  :-> 30
Would you like 2 continue??(Y/N):-> N

/**********************************************************************************************
FILEVIEW
**********************************************************************************************/
01VD 050060070180 02AMIT 070050030150
  
Share: 



Meryl Schmidt
Meryl Schmidt author of Program for, asks user to input data and stores it in to the file is from Frankfurt, Germany.
 
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!