Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

COBOL ASSIGNMENT HELP!

Posted on 2004-10-25
2
Medium Priority
?
784 Views
Last Modified: 2013-11-25
Greetings!

First, I would like to add...it would be nice for this site to have a 'COBOL' section. Since, it doesn't I really didn't know where to ask my question.

Problem, I just started this COBOL class last week and I have no previous experience in programming what so ever. My instructor has given us our first assignment to write a COBOL program that prepares a credit report. Here are the instructors details:

INSTRUCTIONS
A credit report is to be prepared. Write the COBOL program to prepare this report. Use data set 2248DATA.TXT.

INPUT
Input consists of Credit Records that contain the account number, customer name, balance, and purchases. The format of the Credit Record is illustrated below.

Credit Record
Field Name      Position      Length      Dec      Attribute
UNUSED                      1 - 6        6                      Alphanumeric
Account Number      7 - 12      6      0      Numeric
Customer Name      13 - 32      20             Alphanumeric
UNUSED                      33 - 53      21             Alphanumeric
Balance                      54 - 59      6      2      Numeric
Purchases                      60 - 65      6      2      Numeric
UNUSED                      66 - 67      2             Alphanumeric
                               Record Length:  67

OUTPUT
Output consists of a Credit Report listing the account number, customer name, balance, purchases, credit limit, and available credit. To calculate available credit, add balance and purchases and subtract the result from the credit limit. The credit limit for all customers is $1500.00. Account number, balance, purchases and credit limit are to be zero suppressed. Available credit is to be printed using a floating dollar sign. The printer spacing chart for the report is available in SpCharts.xls.

Intructor's tips:

Programming Tips for Program 2

This file is intended to provide you with some additional help in solving problems associated with program 2.  You should be able to use program 1 as a guide for the straightforward movement of data from the input record to the output record, but there are a couple of new concepts to mention.

First, this program has two input fields that must be used in a calculation; therefore, they must be defined as numeric fields.  Second, these fields have decimal positions.  If you examine the input file that we use, you will find that decimals are not stored.  We read this data in using an implied decimal, designated with the letter V.  Lastly, you are told that the length of these fields is 6 with 2 decimal places.  This means the field itself is 6 in length, with 2 of those 6 positions on the right side of the decimal.  The pictures of these two fields should appear as follows (you can give the fields any name you choose, not necessary to name them what I name them):

            05      IN-BALANCE      PIC 9999V99.
            05      IN-PURCHASES      PIC 9999V99.

You also have a requirement in this program to do a calculation for each record and include the results in your detail line.  

      a.  Declare the following items in WORKING-STORAGE:

            01      WS-LIMIT            PIC 9999V99 VALUE 1500.00.
            01      WS-AVAILABLE      PIC 9999V99.

b.  The program instructions tell you that available credit is calculated by adding BALANCE and PURCHASES and subtracting from the credit limit.  The line of code to accomplish this can be done in several ways.  One example is as follows:
            
                  COMPUTE WS-AVAILABLE = WS-LIMIT – (IN-BALANCE + IN-PURCHASES)

Remember, this calculation is done for each detail line, and WS-AVAILABLE represents the last field that is to be displayed on each detail line.  Once again, remember that in order to use a variable in an arithmetic expression, it cannot be numeric edited.  That means no dollar signs, periods, commas, etc. - only 9 or V (an S also if you need to identify that the number could be negative, but you won’t need to do that for this program).

This is what I got so far....I am completely lost on the 'procedure division'. I can't find any examples that will help me understand how to complete this last part. This is my source code:

IDENTIFICATION DIVISION.
 PROGRAM-ID.  PROGRAM2.
*
 ENVIRONMENT DIVISION.
 CONFIGURATION SECTION.
 INPUT-OUTPUT SECTION.
 FILE-CONTROL.
     SELECT CREDITRECORD-FILE
         ASSIGN TO "2248DATA.TXT"
         ORGANIZATION IS LINE SEQUENTIAL.
     SELECT REPORT-FILE
         ASSIGN TO "CRPROG2.TXT"
         ORGANIZATION IS LINE SEQUENTIAL.
*
 DATA DIVISION.
 FILE SECTION.
 FD  CREDITRECORD-FILE
       RECORD CONTAINS 67 CHARACTERS
       LABEL RECORDS ARE OMITTED
       DATA RECORD IS CREDITRECORD-RECORD.
 01  CREDITRECORD-RECORD.
     05  FILLER                       PIC     X(6).
     05  ACCOUNT-NUMBER      PIC     9(6).
     05  CUSTOMER-NAME       PIC     X(20).
     05  FILLER                        PIC     XX.
     05  IN-BALANCE                PIC     9999V99.
     05  IN-PURCHASES            PIC     9999V99.
     05  FILLER                        PIC     XX.
 FD  REPORT-FILE
       RECORD CONTAINS 132 CHARACTERS
       DATA RECORD IS REPORT-RECORD.
 01  REPORT-RECORD.
 WORKING-STORAGE SECTION.
 01  WS-LIMIT                   PIC     9999V99 VALUE 1500.00.
 01  WS-AVAILABLE            PIC     9999V99.
     05  FILLER                    PIC     X       VALUE "$".
*
 PROCEDURE DIVISION.
*
 MAIN-ROUTINE.
     OPEN INPUT CREDITRECORD-FILE
         OUTPUT REPORT-FILE
     READ CREDITRECORD-FILE
         AT END MOVE "
 


Please help!!!

Thanks

BTW, is there a way to upload files on here?


0
Comment
Question by:Chantimeeka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 12402299
>>BTW, is there a way to upload files on here?
Unfortunately no.

As far as homework goes please read
http://www.experts-exchange.com/help.jsp#hi56
http://www.experts-exchange.com/help.jsp#hi105

It has been too long since I did any COBOL but the basic idea will be

Loop
  Read a record
  Calculate the value
  Write a record
Until out of data

mlmcc


0
 
LVL 2

Accepted Solution

by:
mitchellm44 earned 1500 total points
ID: 12587992
It looks like your assignment was a few weeks ago, and this might be a bit late.

You should look into structured programming..

eg.   1000-Main
                open files.
                Perform 9000-read
                perform 2000-processing until EOF.
                perform 8000-output.
                close files
        1000-exit.
        2000-processing
                             
               process logic goe here for each rec
               perform 8000-ouptut
               perform 9000-read.

        2000-exit. exit.
        8000-output.
              print format of line
              check for lines on page and redo headers if needed.
        8000-exit.
        8100-headers
               do header formats
        8100-exit.
        9000-read-file.
                 read input file. add to record count.
        9000-exit.
 
Keep functions simple.   8000 range for common output
                                     9000 range for common inputs
arranging numerically helps you look for it in the right sequence.
Use EJECT to have paragraphs start on new pages when you print out listings..
It has been about 10 years since I touched this stuff.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
The viewer will learn how to implement Singleton Design Pattern in Java.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question