CSCI 360 | Spring 2014 |
For this assignment, write a program that will perform mathematical calculations on two numbers.
The program should have a read loop that will process the input one record at a time.
For each input record, print a detail line containing the calculation type, the input values, and the result of the calculation. NOTE: for a divide calculation, there will be two results: the quotient and the remainder.
After all of the calculations have been performed, display a summary listing of the total number of calculations, as well as the total number of each individual calculation type.
The input to the program will be a file with an unknown number of records. Each record represents a single calculation and has the following format:
columns description ------- ----------- 1 Calculation Type Code 2 - 4 spaces 5 - 9 First Number 10 - 12 spaces 13 - 17 Second Number 18 - 80 spaces
The calculation type code is a numeric value that corresponds as follows:
Code Calculation Type ---- ---------------- 1 Addition 2 Subtraction 3 Multiplication 4 Division
For all of the calculation types, the operation should be applied in the order: First Number operator Second Number.
Use M, D, MR, DR, LA, XREAD, XDECI, XDECO, XPRNT, L, ST, C, A, S, AR, SR,
BC
, and BCR
, as appropriate.
Use at least one literal in the program.
Use line documentation, documentation boxes, TITLE, EJECT
, and
SPACE
as before.
Write this program incrementally. It will be much easier to debug. Initially write the program so that it reads and processes one record. Once you know it does that correctly, implement the loop.
Hand in a copy of your source code AND a listing of the Marist output on Blackboard.
Use the following JCL statement to specify the input file:
//FT05F001 DD DSN=KC02330.CSCI360.FILES(DATA3),DISP=SHR
The JCL for the program should now look like:
//your_KC_id_plus_a_letter JOB ,'your name',MSGCLASS=H //STEP1 EXEC PGM=ASSIST //STEPLIB DD DSN=KC02293.ASSIST.LOADLIB,DISP=SHR //SYSPRINT DD SYSOUT=* //SYSIN DD * ******************************************** * * The program goes here * ******************************************** /* //FT05F001 DD DSN=KC02330.CSCI360.FILES(DATA3),DISP=SHR //
When you are debugging logic errors, don't be reluctant to use XDUMP instructions to display registers and/or memory. Once you get the program running, remove the XDUMPs from the run that is turned in for grading.
Feel free to test the program with your own data. Simply leave out the FT05F001 statement in the JCL that was given above and place your data after the assembly END statement. It is important that the data you enter follows the same format as the grade run input file. For example:
END MAIN 1 987 45 3 12345 3 3 9 999 4 5890 4 2 38 9308 /* //
Make sure that the run you hand in for grading uses the file specified above and contains nothing after the END statment.
The output for the program should resemble the following:
Results of Arithmetic Operation Num 1 Num 2 Result --------------------------------------------------------------------------------------------------- Addition 987 45 Sum: 1032 Multiplication 12345 3 Product: 37035 Multiplication 9 999 Product: 8991 Division 5890 4 Quotient: 1472 Remainder: 2 Subtraction 38 9308 Difference: -9270 Total Calculations: 5 Addition: 1 Subtraction: 1 Multiplication 2 Division: 1
The page header for the report should start at the top of a new page. The column headers should be double spaced from the page header. The calculation information should be double spaced. The summary lines should be triple spaced from the last calculation record.