All of us mention our GPAs in the CV. Some of us are not so proud of the scores ;)
But have you ever wondered that you can write the logic of GPA Calculation using pure COBOL Code?
Have a look!
But have you ever wondered that you can write the logic of GPA Calculation using pure COBOL Code?
Have a look!
****************************************************************** * This program determines the semester GPA and the cumlative GPA * of the student. The user inputs their student number, then * asks for info about one course which is the course number, * credits, and grade. * * ****************************************************************** * Environment Division. * Data Division. * Working-Storage Section. * 01 WS-Student-Data. * 05 WF-Student-Number pic 9(5). 05 WF-Course-Number pic 9(6). 05 WF-Credit-Hours pic 9. 05 WF-Grade pic 99. 01 WS-Switches. 05 WD-Response pic x(3). 05 WD-New-Student pic x(3). 01 WS-Total. 05 WT-Student-Count pic 9(3). 05 WT-Cumlative pic 99v999. 05 WT-Credits pic 99. 05 WT-Total-Grade pic 99. 05 WT-All-Students-GPA pic 99v999. 05 WT-All-Students-Credits pic 999. * Procedure Division. * 000-Main-Rtn. * Perform 100-Init-Rtn Thru 100-Init-Rtn-Exit Until WD-Response = 'no' Perform 200-Process-Rtn Thru 200-Process-Rtn-Exit Until WD-Response = 'no' Perform 300-Display-Rtn Thru 300-Display-Rtn-Exit Display 'END OF SESSION'. * 100-Init-Rtn. * Display 'Please enter your student number & press enter key' Accept WF-Student-Number Display 'Please enter the course number & press enter key' Accept WF-Course-Number Display 'Please enter the number of credits & press enter' Accept WF-Credit-Hours Display 'Please enter your grade & press enter key' Accept WF-Grade. If WF-Grade = 'A' Add 4 to WF-Grade If WF-Grade = 'B' Add 3 to WF-Grade If WF-Grade = 'C' Add 2 to WF-Grade If WF-Grade = 'D' Add 1 to WF-Grade If WF-Grade = 'F' Add 0 to WF-Grade Add WF-Credit-Hours to WT-Credits Add WF-Grade to WT-Total-Grade Display 'Do you have another class to enter yes/no?' Accept WD-Response if WD-Response = 'no' Display WF-Student-Number Divide WT-Total-Grade by WT-Credits giving WT-Cumlative Display WT-Cumlative Add WT-Cumlative to WT-All-Students-GPA Add WT-Credits to WT-All-Students-Credits. * 100-Init-Rtn-Exit. Exit. * 200-Process-Rtn. * Initialize WD-Response Initialize WD-New-Student Display 'Is there another students GPA you wish to -'enter yes/no'. if WD-New-Student = 'yes' add 1 to WT-Student-Count Accept WD-New-Student Display 'Please enter your student number & press enter key' Accept WF-Student-Number Display 'Please enter the course number & press enter key' Accept WF-Course-Number Display 'Please enter the number of credits & press enter' Accept WF-Credit-Hours Display 'Please enter your grade & press enter key' Accept WF-Grade. Display 'Do you have another class to enter yes/no' Accept WD-Response. if WD-Response = 'no' Display WF-Student-Number Divide WT-Total-Grade by WT-Credits giving WT-Total-Grade WT-Credits Display WT-Cumlative Add WT-Cumlative to WT-All-Students-GPA Add WT-Credits to WT-All-Students-Credits. 200-Process-Rtn-Exit. Exit. * 300-Display-Rtn. * Divide WT-All-Students-GPA into WT-All-Students-Credits Display WT-All-Students-Credits. * 300-Display-Rtn-Exit. Exit.
No comments:
Post a Comment