-
Notifications
You must be signed in to change notification settings - Fork 0
/
SinTest.cbl
49 lines (34 loc) · 1.35 KB
/
SinTest.cbl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
program-id. SinTest.
environment division.
configuration section.
data division.
working-storage section.
01 AMPLITUDE PIC 9(4) VALUE 50.
01 OFFSET PIC 9(4) VALUE 1.
01 ITERATIONS PIC 9(4) VALUE 1000.
01 DECIMAL-VAL PIC S99V9(5) VALUE 0.0.
01 DEC-CALCULATED PIC S99V9(5).
01 ROUND-INT PIC 9(4).
01 MESSAGE-STRING pic x(5) value "COBOL".
linkage section.
procedure division.
PERFORM ITERATIONS TIMES
*> Calculate spaces needed
COMPUTE DEC-CALCULATED = FUNCTION SIN (DECIMAL-VAL)
ADD OFFSET TO DEC-CALCULATED
MULTIPLY AMPLITUDE BY DEC-CALCULATED
*> Round to int so we can use it as a counter
*> Literally just jamming the decimal number into an int
*> I don't know if this is bad
COMPUTE ROUND-INT = DEC-CALCULATED
*> Loop for all needed spaces
PERFORM ROUND-INT TIMES
*> NO ADVANCING to stop new line
DISPLAY " " NO ADVANCING
END-PERFORM
DISPLAY MESSAGE-STRING
*> DISPLAY DEC-CALCULATED
ADD 0.1 TO DECIMAL-VAL
END-PERFORM.
goback.
end program SinTest.