Fixing a Bug in a COBOL Program

Fixing a Bug in a COBOL Program Bug Overview A COBOL program responsible for calculating and displaying a Total Price for customer orders contained a bug. The calculation logic was incorrect, causing the Total Price to display a value of 0.00 under certain conditions. This article documents the problem, the root cause, and the implemented fix. Original Buggy Code The bug was traced to a missing initialization of the TOTAL-PRICE field and an incorrect placement of the computation logic. 01 ORDER-DETAILS. 05 QUANTITY PIC 9(3). 05 UNIT-PRICE PIC 9(5)V99. 05 TOTAL-PRICE PIC 9(7)V99. ... DISPLAY "Order Information". DISPLAY "Quantity : " QUANTITY. DISPLAY "Unit Price : " UNIT-PRICE. DISPLAY "Total Price : " TOTAL-PRICE. Problem: TOTAL-PRICE was displayed without being computed. No computation logic was included to multiply QUANTITY by UNIT-PRICE . Fixed...