Lab 4

Goals

  • PERFORM and IF statements
  • Condition Names
  • Data Validation
  • Single-level control break algorithm

Part A – Data Validation

Write a COBOL program called lab4a.cob to detect input errors and write findings to an output error report.

The name of the input file to use is ~sgomori/students/cis314/lab4ain.dat. Copy this file to your own directory for use in writing the COBOL program. The format for this input file is the same as that of the input file for lab3c.

  • Employee Number – length 5
  • Employee Name – length 20
  • Department – length 15
  • Pay Code – length 1
  • Number of Hours Worked – length 2
  • Hourly Wage – length 7

Notice that the input format is not given. A problem you need to solve for here is how to define the input data item (in the input file record description) to correctly check for invalid data.

lab4a.cob should catch the following data entry errors:

  • non-numeric employee number
  • negative employee number
  • non-numeric number of hours worked
  • negative number of hours worked
  • non-numeric hourly wage
  • negative hourly wage
  • non-alphabetic employee name
  • non-alphabetic department
  • invalid pay-code (not 'H', 'h', 'S', 's')

Be sure to include at least one class test, one sign test and one relation test.

Create an output error report file named lab4aout.dat. This file should contain an error message along with the offending input record for each error found in the file. Should you find two errors in one record, output two error messages but the data record only once. Also, count the total number of records that have errors in them as well as the total number of errors detected (since you can have more than 1 error per record). Output these two pieces of information at the end of your output error file. Choose how you would like to output your information. Here is a sample:

 
  Non-numeric employee number found in the following input record:
     ... output the input record exactly how it occurs in the input file (in one piece)
 
     a blank line or delimiter of some kind to denote different records
     
  Non-numeric number of hours in the following input record:
  Negative hourly wage owed in the following input record:
     ... output the input record exactly how it occurs in the input file (in one piece)
 
                  etc.
 
  Total number of invalid records:             9,999
  Total number of invalid input data items: 9,999

Part B – Single Control Break Algorithm

Write a COBOL program named lab4b.cob to accomplish the following.

Note: This will be similar to lab3c.cob, so you should use that as a starting point. If you were not able to complete lab3c.cob properly please see your grader/instructor for help in making your program correct before continuing on with this problem.

PROBLEM

Many hospitals are a part of the United Healthcare of Ohio (UHOH) Insurance system. Each hospital accepting UHOH Insurance has a unique numeric identification number. UHOH Insurance would like a report to determine the total and average amount of unpaid bills still owed for each hospital as well as the grand total and average amount of unpaid bills for all of the unpaid bills in the UHOH Insurance system.

INPUT

The input file ~sgomori/students/cis314/lab4bin.dat has been created for you and has the following specifications for each billing recipient. You do not know how many records are in the input file or how many records each hospital has. However, you do know that the input file is sorted by hospital number. You may assume that this file has no invalid data.

  • Hospital Number – format 999
  • Hospital Name – format X(20)
  • Patient Number – format 99999
  • Patient Name – format X(20)
  • Address – format X(30)
  • Date of Service – format 9(8) (MMDDYYYY)
  • Bill Amount Owed – 9(7)V99

OUTPUT

The report file will be named lab4bout.dat. The output should look basically like the following:

Each Page Header should look something like this:

 
Date: MM/DD/YYYY                            NAME OF INSURANCE SYSTEM                          Page 999
Time: HH:MM:SS

At the start of each set of hospital data you are to print the hospital name and number, as is shown below.

 
HOSPITAL NAME:   name of hospital
HOSPITAL NUMBER: unique hospital id number

At the top of each page, after the page header, you will print the two lines of column headings, as well as the lines for hospital name and number. You should have something like this:

 
Patient      Patient                                                Date of           Amount
Number        Name                     Address                      Service            Owed
 
HOSPITAL NAME: name of hospital
HOSPITAL NUMBER: unique hospital id number
 
00001    Johnson, William     2015 Neil Ave Columbus OH 43210      08/24/1999      $1,232,450.50

Once the data for each hospital has printed, output the average and total bill amounts owed for that hospital (using proper editted output):

 
The average bill amount owed is:   $9,999,999.99
The total bill amount owed is:   $999,999,999.99

Once the end of the input file is detected, output (using proper edited output):

The average bill amounted owed for UHOH Insurance is:     $9,999,999.99
The total bill amount owed for UHOH Insurance is:     $9,999,999,999.99

Submitting Lab 4

The files to submit are:

  • lab4a.cob
  • lab4b.cob

Deleting Unnecessary Files

Use the clean utility described in Lab 2.