Q. Can the Mainframe computer do Math? 
My Math professor at school taught me, how to calculate the Simple Interest on a Principal amount. The formula for SimpleInterest is I = P x R x T. Mainframe Computers are good at Math. I am going to feed this formula into the Mainframe Computer. Then, I’ll have my computer calculate the SimpleInterest. 
Q. Could you draw a Flowdiagram on how to calculate the SimpleInterest? 
I have to calculate the Simple Interest to be charged for ten customers, who have borrowed money from the bank. The Inputfile contains a list of ten records, one record for each customer, and each record specifies the Principal, RateofInterest and Time. Now, here's a flowchart that outlines the steps, to calculate the SimpleInterest to be charged. First, the InputFile is opened for reading data. The OutputFile is Opened for writing Output results. The Input File contains the Principal(P), Interest Rate(R), and Time(T). The program has to calculate the Interest(I), and write this answer to the Output File. The Input File contains ten records. The records from the file are read onebyone sequentially. In each record, the P,R and T values are taken as input. The P value is multiplied by R, and stored in an intermediate Product. This Product is then further multiplied by T, and the final output interest is obtained. This output interest is written(stored) to the outputfile. This process is repeated over and over again, ten times, until all the records have been

Q. How to code the IDENTIFICATION and ENVIRONMENT DIVISION of the COBOL Program? 
The Programid is PROG14. This COBOL Program accesses two FlatFiles – the Input File with Datarecords and an Output File to store the results. The SELECT statement in the FILECONTROL Para, of the INPUTOUTPUT SECTION under the ENVIRONMENT DIVISION, declare the internal COBOL Filename INPUTFILE and OUTPUTFILE. The symbolic DDNames of the two files are INFILE and OUTFILE.

Q. What is the data in the InputFile? What is its Format? 
The Physical Mainframe Dataset SYSADM.DEMO.INPUT contains the Datarecords to be processed by the Program. The contents of SYSADM.DEMO.INPUT are shown below. Every Record in the File has a Fixed Record Length(LRECL) of 80 Bytes. Thus, in the COBOL Program, the File Buffer for the INPUTFILE should be 80 Bytes large. But, every INPUTRECORD in the Input File, can be broken down into three parts – Principal(P), RateofInterest(R), Time(T). For example, in the first record, P=001000.00, R=.0150, T=05 Years. In the second record, P=000700.00, R=.0275 and T=05 Years. Every record has this format; the first 8 Bytes are P(Principal) value, the next 4 Bytes are R(Rateofinterest) value, the next two bytes are T(Time) value and the last 66 Bytes don’t contain any data. Thus, I am going to breakup INPUTRECORD as follows :

Q. What the Output File looks like? What is its format? 
I shall use the Mainframe Dataset SYSADM.DEMO.OUTPUT to store Output Results, after calculating the Simple Interest. The contents in SYSADM.DEMO.OUTPUT look like this  The first twelve Bytes in the OutputFile will be used to store the Simple Interest Answer. The next 68 Bytes do not contain any data. I am gonna define a File Buffer for the OutputFile as follows 

Q. What are Working Storage Areas? 
As a kid, when you took your Math examinations, you'd usually pick up the Input datavalues supplied in the Question Paper, take a rough sheet, or a scratchpad, apply the Math formula, work out the problem in roughwork sheet. When arrive at the final answer, you jot it down on the answersheet. Think of the INPUTFILE to be your Math Question Paper, that supplies the PRINCIPAL, RATEOFINTEREST and TIMEPERIOD Values. The OUTPUTFILE is your Answer Sheet, where you put down the final answer in the SIMPLEINTEREST Field. For working out the problem, you need memory space. Storage Areas which are merely used to do RoughWork, and store intermediate results of processing, before you arrive at the final answer are call RoughWork Areas or Working Storage Areas. 
Q. How Roughwork areas can help me out here? 
To begin with, I shall copy over all the data from the Question Paper(Input File) to my Rough Work Sheet. How is this done? Just as in algebra, there are algebraic variables like P,R and T, similarly in COBOL you can have roughwork variables like P,R and T. Since, they are being used for RoughWork(Workingstorage), I am prefixing their names with 'WS', so they become WSP, WSR and WST. Now, I am gonna put down all the data supplied in the Questionpaper, onto the Rough Work Sheet. I am gonna copy over value 1000 from the PRINCIPAL Field of the INPUTFILE, into the WSP variable in the RoughWork area. Likewise, I shall copy over the value 0.150 from RATEOFINTEREST Field of the Input File, to WSR in RoughWork area. I copied over the value 05 from the TIMEPERIOD Field of the INPUTFILE into the WST Variable on the RoughWork Sheet. Now, I have all the data on the roughwork sheet. Since, WSP, WSR and WST are meant for roughwork, I should also declare them under the WORKINGSTORAGE SECTION of my COBOL Program. Generally, the WORKINGSTORAGE SECTION is coded right after the FILE SECTION of a COBOL Program. So, here's how the WORKINGSTORAGE would look  The WORKINGSTORAGE SECTION declares(announces) the list of all Variables(StorageAreas) which are used only for RoughWork. While coding the COBOL Program, I am gonna keep adding more to list of WORKINGSTORAGE Variables, as and when I need them. Back to working out the Problem. Now that, I have all the data on the RoughWork Sheet in WSP, WSR and WST. I know, that the formula for Simple Interest is I = P x R x T. Let's move ahead one step at a time. I would first multiply P with R, and store this result in a RoughWork variable WSPRODUCT. I would have to add WSPRODUCT to list of WORKINGSTORAGE Areas. Here, you go. Well, I now need to take the Intermediate WSPRODUCT of P x R, and mutiply this with T, to get the Interest I.
