This is an open book, open notes quiz. The quiz is to be turned in by 8:30 PM. Most of these questions have long answers that you should write on your own paper.
Explain how the following two COBOL features can be used to write programs that carefully validate their input
Now illustrate your skills at input validation by writing one or two relevent COBOL record definitions along with a COBOL paragraph that reads a record containing seven characters and verifies that those seven characters contain a valid integer.
Given a COBOL program with the following data description entries
02 A-FIELD PIC $99,999.99CR. 02 B-FIELD PIC $$$,$$$.99. 02 C-FIELD PIC ***,***.99-. 02 D-FIELD PIC +++,+++.99. 02 E-FIELD PIC ---,--9.99.
What would be printed if each these field were to receive the following values
To make my life easier, here's a table for you to fill in
-15,377.45 | 15,247.88 | 19.96 | |
$99,999.99CR | |||
$$$,$$$.99 | |||
***,***.99- | |||
+++,+++.99 | |||
---,---.99 |
There is one very important assumption regarding the input to control break programs. What is that assumption?
Suppose you have a field called FRUITthat can have two possible values: "APPLE"and "GRAPE". Show how to define two condition names LIKES-APPLESand LIKES-GRAPESfor testing these two values.
Suppose the input file to a program is in the following format:
Character positions | Field value |
---|---|
1-20 | Student name |
21-30 | Student id |
31-33 | Country of residence |
33-34 | State of residence |
35-44 | County of residence |
45-47 | Credit hours transfered |
48-50 | Credit hours passed at UNCA |
51-55 | Library fines |
where library fines are entered with an implied decimal place, i.e., a library fine $17.58 is entered as 01758. Give a file descriptor (FD) entry suitable for reading records from this input file.
Now write a COBOL PROCEDURE DIVISIONthat could read the input records described in Problem 6 and calculate and print the total amount of fines owned by students from the state of North Carolina. These students will have a country code of "USA"and a state code of "NC".
Now write a COBOL PROCEDURE DIVISIONthat will read the input records described in Problem 6 and produce an output file in the exact same format. The output file should be identical to the input file excapt that the library fines of each South Carolina resident should be increased by 10 cents and the fine of each North Carolina residents should be decreased by the lesser of 5 cents or the present fine. (That is, don't let anyone owe less than 0 cents.)
Either name one characteristic of a good mentor mentioned in Janet Cody's talk or name one way of increasing object reuse mentioned in Deb Bowles' talk.
Back to the exams and quizzes index
Back to the CSCI 241 home page