ACCEPT, DISPLAY, WRITE, PERFORM..UNTIL


Introduction

Using Seqread.cbl as a starting point, write a program called SeqWrite.cbl to accept student records from the user and write them to a file (MyStudents.dat). The program should keep accepting records from the user until spaces are entered instead of a record (i.e. the Enter key is pressed without having entered any data). No error checking on the data entered is required.

The program should prompt the user for each record and should provide a template to make it more easy to enter the data correctly (see Example Run below).

Output File

The student records accepted from the user must be written to a file. Each record will have the following description.

Field Type Length Value
Student Id 9 7 0-9999999
Student Name . . Group
Surname X 8 -
Initials X 2 -
Gender X 1 M/F
Example run
Please enter the student record using the template below.
Press the Enter key with no data to stop.
nnnnnnnSSSSSSSSiiG
9765321COUGHLANMSM
9787654RYAN    GTF
9734563POWER   RGM
9734562SMITH   WBM
9765341KENNEDY DSF
   enter

Further Work

Add code to your program to read the file you have just created and display the records. Display the records as shown in the example run below.

Example run
Stud-Id  Student Name Gender
9765321  COUGHLAN MS    M
9787654  RYAN     GT    F
9734563  POWER    RG    M
9734562  SMITH    WB    M
9765341  KENNEDY  DS    F

Example Program

When you have written your program and have compiled it and have it working correctly, you may wish to compare it with this sample solution.

WARNING

Do not look at the solution until you have finished your own or at least have made a substantial effort to complete it.