-
Notifications
You must be signed in to change notification settings - Fork 2
/
decibel-calc.bas
149 lines (149 loc) · 2.89 KB
/
decibel-calc.bas
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
100 REM THIS IS PROGRAM NO. 29 PROG29
105 V1 = 0
106 V2 = 0
107 I1 = 0
108 I2 = 0
109 P1 = 0
110 P2 = 0
120 PRINT "WHICH OF THE FOLLOWING IS REQUIRED?"
130 PRINT
140 PRINT "1. DECIBEL CONVERSION GIVEN"
145 PRINT " VOLTAGE, CURRENT OR POWER"
146 PRINT " RATIOS."
147 PRINT
150 PRINT "2. VOLTAGE, CURRENT OR POWER"
155 PRINT " RATIOS NEEDED FOR GIVEN"
158 PRINT " DECIBEL LEVEL."
160 PRINT
170 PRINT "SELECT ONE FROM ABOVE AND PRESS CR..."
180 INPUT S
185 PRINT S
190 IF S > 2 THEN GOTO 120
200 ON S GOTO 210,600
210 GOSUB 1000
220 PRINT "WHICH CALCULATION IS DESIRED?"
230 PRINT
240 PRINT "1. VOLTAGE RATIO"
250 PRINT "2. CURRENT RATIO"
260 PRINT "3. POWER RATIO"
270 PRINT
280 PRINT "SELECT ONE FROM ABOVE AND PRESS CR..."
290 INPUT Q
295 PRINT Q
300 IF Q > 3 THEN GOTO 220
310 ON Q GOTO 320,390,460
320 GOSUB 960
330 PRINT "ENTER V1:"
340 INPUT V1
345 PRINT V1
347 PRINT
350 PRINT "ENTER V2:"
360 INPUT V2
365 PRINT V2
367 PRINT
370 DB = 20*(LOG(V1/V2)/LOG(10))
380 GOTO 520
390 GOSUB 960
400 PRINT "ENTER I1:"
410 INPUT I1
415 PRINT I1
418 PRINT
420 PRINT "ENTER I2:"
430 INPUT I2
435 PRINT I2
438 PRINT
440 DB = 20*(LOG(I1/I2)/LOG(10))
450 GOTO 520
460 GOSUB 960
470 PRINT "ENTER P1:"
480 INPUT P1
485 PRINT P1
490 PRINT "ENTER P2:"
500 INPUT P2
505 PRINT P2
508 PRINT
510 DB = 10*(LOG(P1/P2)/LOG(10))
520 PRINT
530 DB = DB*100
540 DB = INT(DB)
550 DB = DB/100
560 PRINT "RATIO REPRESENTS: ";DB;" DB"
570 PRINT
580 GOSUB 1040
590 GOTO 1070
600 GOSUB 1000
610 PRINT "SELECT ONE FROM MENU BELOW:"
620 PRINT
630 PRINT "1. VOLTAGE RATIO"
640 PRINT "2. CURRENT RATIO"
650 PRINT "3. POWER RATIO"
660 PRINT
670 PRINT "SELECT ONE FROM MENU BELOW:"
620 PRINT
630 PRINT "1. VOLTAGE RATIO"
640 PRINT "2. CURRENT RATIO"
650 PRINT "3. POWER RATIO"
660 PRINT
670 PRINT "ENTER ONE FROM ABOVE AND PRESS CR..."
680 INPUT L
685 PRINT L
688 PRINT
690 IF L > 3 THEN GOTO 610
700 GOSUB 960
710 PRINT "ENTER NUMBER OF DECIBELS:"
720 INPUT DB
725 PRINT DB
738 PRINT
740 ON L GOTO 750,770,790
750 RA = (10^(DB/20))
760 GOTO 800
770 RA = (10^(DB/20))
780 GOTO 800
790 RA = (10^(DB/10))
800 PRINT
810 RA = RA*100
820 RA = INT(RA)
830 RA = RA/100
840 PRINT
850 PRINT DB;" DB REPRESENTS A"
860 ON L GOTO 870,890,910
870 PRINT "VOLTAGE RATIO OF ";RA;":1"
880 GOTO 930
890 PRINT "CURRENT RATIO OF ";RA;":1"
900 GOTO 930
910 PRINT "POWER RATIO OF ";RA;":1"
920 GOTO 930
930 PRINT
940 GOSUB 1040
950 GOTO 1070
960 FOR I = 1 TO 5
970 PRINT
980 NEXT I
990 RETURN
1000 FOR I = 1 TO 30
1010 PRINT
1020 NEXT I
1030 RETURN
1040 PRINT "PRESS CR TO CONTINUE..."
1050 INPUT KK
1055 PRINT KK
1058 PRINT
1060 RETURN
1070 GOSUB 1000
1080 PRINT "FINISHED?"
1090 PRINT
1100 PRINT "1. YES"
1110 PRINT "2. NO"
1120 PRINT
1130 PRINT "SELECT ONE FROM ABOVE AND PRESS CR..."
1140 INPUT Z
1145 PRINT Z
1150 IF Z > 2 THEN GOTO 1080
1160 ON Z GOTO 1170,110
1170 GOSUB 1000
1180 FOR I = 1 TO 20
1190 PRINT "********** BYE-BYE ********"
1200 NEXT I
1210 GOSUB 960
1220 PRINT "PROGRAM ENDED"
1290 END