AU03LabQuiz4A

advertisement
AU03 CIS314 LAB #4 EXAM
NAME______________________________________________
GRADE _______/15.0
Directions: If you have a question, please raise your hand. If an answer is not legible, it will be counted
incorrect. Remain seated until you are ready to turn in your quiz.
The COBOL debugger (5 points)
T
F
The COBOL debugger is case insensitive.
T
F
A breakpoint allows the programmer to jump to an important part of a program without stopping at every
statement.
T
F
Using the single step command is equivalent to performing a program walkthrough.
T
F
The g command will always execute the program until the end without stopping.
T
F
The b command will must always be followed by a paragraph name.
STRING/UNSTRING (5 points) – An input file exists with records that have no uniform spacing. That is, the
record must be read in as a whole, with no separate fields.
FD input-file.
01 input-rec pic x(20).
Each input record contains a college name followed by a blank and the name/type of the school mascot. The
output file should have two records for each one input record. The first line contains the name of the school
with a blank and the word “university” following it and the second line is the name of the mascot. Write the
string and unstring statements to complete the program code given.
Input: college mascot
Auburn Tigers
Ohio Bobcats
Oklahoma Sooners
Yale Bulldogs
Output:
Auburn University
Tigers
Ohio University
Bobcats
Oklahoma University
Sooners
Yale University
Bulldogs
FD output-file.
01 output-rec pic x(30).
…
working-storage section.
77 eof …
77 college-name pic x(30).
77 mascot
pic x(30).
77 university
pic x(10) value “University”.
Procedure division.
100-main.
open…
read input-file at end…
perform until eof
Syntax definitions for STRING and UNSTRING
STRING { {identifier-1 | literal-1}
DELIMITED BY {identifier-2 | literal-2 | SIZE} } …
INTO identifier-3
[END-STRING]
UNSTRING identifier-1
DELIMITED BY {identifier-2 | literal-1}
[ OR {identifier-3 | literal-2} ] …
INTO identifier-4…
[END-UNSTRING]
read input-file at end…
end-perform.
…
AU03 Lab #4 Exam A
Double Control Break Algorithm (5 pts)
Problem: An input file contains information about Dog Owners/Breeders and their dogs. Each owner has a breeder
number and each dog has an identification number. Part of the dog’s identification number is the litter number. The AKA
(American Kennel Association) wants a report that lists every breeder and the dogs owned by that breeder by litter.
There is an input record for each dog owned by the Breeder. Each record contains the following data:
Breeder Number
Sample input file:
Breeder Name
94Kyle Hutchins
4M43Preston
10032002
Dog identification number
94Kyle Hutchins
4M41Jake
10032002
Litter number
94Kyle Hutchins
2M73Happy
11022002
Gender
94Kyle Hutchins
2F77Runt
11022002
Number in litter
83John
Smith
2M32Cutie
10282002
When pup born in relation to rest of litter ( i.e. 4th of 9)
83John Smith
1F31Thor
10022002
Dog name
83John Smith
1M33Hunter
10022002
Date born
 Normally, the report would be by breeder then by litter. If this is the case, which piece of data would we check for a
control break first in the program?
_________________________
 Can the report be listed correctly by litter number then by breeder number (yes/no)? _________ Explain.
 Without using tables or opening the input file multiple times (or any other stuff we have yet to learn in class at this
point), how can we get the output report to be in order by breeder number?
 Write the psuedocode (remember, procedure division only!) to create the following output report. Do not write the
information in parenthesis… that is just to help you understand what the output data is!
94 (breeder number)
Kyle Hutchins (breeder name)
4 (litter number)
Preston (name of puppy in litter 4)
Jake (name of puppy in litter 4)
2 (litter number)
Happy (name of puppy in litter 2)
Runt (name of puppy in litter 2)
83
John Smith
2
Cutie
1
Thor
Hunter
AU03 Lab #4 Exam A
Download