123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
COBOL ON-SCREEN CALCULATOR (Mini Project)

--------------------------------------------------------------------------------

Description : written in RM-COBOL 77 .. (OK with Cobol85) to implement a simple on-screen calculator.

Code :
IDENTIFICATION DIVISION.
ooo PROGRAM-ID. CALC.

*-----------------------------------------------------------------
ooo * THIS IS CALCULATOR OVERLAY

*-----------------------------------------------------------------
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. RMC-UNIX.
OBJECT-COMPUTER. RMC-UNIX.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 COMMON-DATA.
02 OPERATOR-NUMBER PIC 9(06) VALUE 1.
02 DISP-AMT PIC Z(8).99-.
02 NEW-VALUE PIC S9(8)V99.
02 ACCUMULATOR PIC S9(8)V99.
02 KEYPRESS PIC X.
88 CLEAR-ACCUMULATOR VALUE IS "C".
88 ENDING VALUE IS "Q".
88 VALID-KEY VALUES ARE "+", "*", "/", "-".
01 LIN PIC 99 COMP.

PROCEDURE DIVISION.
BEGIN.
DISPLAY "*** SYSTEM CALCULATOR ***" LINE 1 POSITION 25
ERASE
"Uses + - / * C=Clear Q=Quit" LINE 2 POSITION 25.
MOVE 4 TO LIN.
MOVE 0 TO ACCUMULATOR.
DISP-ACCUM.
MOVE ACCUMULATOR TO DISP-AMT.
DISPLAY "Accumulator" LINE LIN POSITION 2
DISP-AMT LINE LIN POSITION 14
"." LINE LIN POSITION 27
" Function +-/*C" LINE LIN POSITION 29.
ACCEPT KEYPRESS LINE LIN POSITION 27 PROMPT ECHO.
DISPLAY " " LINE LIN POSITION 29 ERASE EOL.
IF CLEAR-ACCUMULATOR GO TO BEGIN.
IF ENDING GO TO END-CALC.
IF NOT VALID-KEY GO TO DISP-ACCUM.
ACCEPT NEW-VALUE LINE LIN POSITION 30 SIZE 10
PROMPT ECHO CONVERT.
MOVE NEW-VALUE TO DISP-AMT.
DISPLAY DISP-AMT LINE LIN POSITION 30.
IF KEYPRESS = "+" ADD NEW-VALUE TO ACCUMULATOR.

IF KEYPRESS = "-" SUBTRACT NEW-VALUE FROM ACCUMULATOR.
IF KEYPRESS = "*" MULTIPLY NEW-VALUE BY ACCUMULATOR ROUNDED.
IF KEYPRESS = "/" DIVIDE NEW-VALUE INTO ACCUMULATOR ROUNDED.
ADD 1 TO LIN.
IF LIN = 22 MOVE 4 TO LIN
DISPLAY " " LINE 1 POSITION 1 ERASE EOS.
GO TO DISP-ACCUM.
END-CALC.
DISPLAY " " LINE LIN POSITION 27 ERASE EOL.
EXIT-POINT.
EXIT PROGRAM.
FALLTHROUGH.
STOP RUN.
--------------------------------------------------------------------------------
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG