-
Notifications
You must be signed in to change notification settings - Fork 2
/
resistors-in-series-or-parallel.bas
95 lines (95 loc) · 2.05 KB
/
resistors-in-series-or-parallel.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
100 REM THIS IS PROGRAM NO. 24 PROG24
110 REM RUNS ON C-64 OR C-128
120 REM
125 REM THIS PROGRAM CALCULATES THE
126 REM VALUE OF N RESISTORS IN PARALLEL
130 DIM R(1000)
140 DIM G(1000)
150 GSUM = 0
160 RSUM = 0
170 GOSUB 520
180 PRINT "HOW MANY RESISTORS ARE THERE?"
190 INPUT N
192 IF N = 1 THEN GOTO 800
193 IF N < 1 THEN GOTO 900
200 GOSUB 520
210 FOR I = 1 TO N
220 PRINT "ENTER R(";I;") IN OHMS:"
230 INPUT R(I)
240 G(I) = 1/R(I)
250 GSUM = GSUM + G(I)
260 RSUM = RSUM + R(I)
270 NEXT I
280 GOSUB 520
290 RTP = 1/GSUM
291 RTP = RTP*100
292 RTP = INT(RTP)
293 RTP = RTP/100
294 RSUM = RSUM*100
295 RSUM = INT(RSUM)
296 RSUM = RSUM/100
300 PRINT "PARALLEL OR SERIES?"
310 PRINT TAB(5);"1. PARALLEL"
320 PRINT TAB(5);"2. SERIES"
330 PRINT TAB(5);"3. BOTH PARALLEL & SERIES"
340 PRINT
350 PRINT "SELECT ONE FROM ABOVE "
355 PRINT "AND PRESS CR"
360 INPUT D
370 IF D > 3 THEN GOTO 300
380 IF D = 2 THEN GOTO 410
390 IF D = 1 THEN GOTO 440
400 IF D = 3 THEN GOTO 470
405 IF D < 1 THEN GOTO 300
410 GOSUB 420
420 PRINT "SERIES OF TOTAL OF ";N;" RESISTORS IS ";RSUM;" OHMS"
430 GOTO 560
440 GOSUB 520
450 PRINT "PARALLEL TOTAL OF ";N;" RESISTORS IS ";RTP;" OHMS"
460 GOTO 560
470 GOSUB 520
480 PRINT "TOTAL PARALLEL RESISTANCE ";RTP;" OHMS"
490 PRINT
500 PRINT "TOTAL SERIES RESISTANCE ";RSUM;" OHMS"
510 GOTO 560
520 FOR I = 1 TO 30
530 PRINT
540 NEXT I
550 RETURN
560 PRINT
570 PRINT "PRESS CR TO CONTINUE..."
580 INPUT KK
590 GOSUB 520
600 PRINT "FINISHED"
610 PRINT TAB(5);"1. YES"
620 PRINT TAB(5);"2. NO"
630 PRINT
640 PRINT "SELECT ONE FROM ABOVE AND"
645 PRINT "PRESS CR..."
650 INPUT F
660 IF F > 2 THEN GOTO 600
670 IF F = 2 THEN GOTO 150
675 IF F < 1 THEN GOTO 600
680 GOSUB 520
690 PRINT "PROGRAM ENDED..."
700 PRINT
710 PRINT
720 GOTO 1000
800 REM ONE RESISTOR ERROR MSG.
810 PRINT "ONE RESISTOR IS A TRIVIAL"
820 PRINT "CASE ...TRY AGAIN"
830 PRINT
840 PRINT
850 PRINT "PRESS CR TO CONTINUE..."
860 PRINT
870 PRINT
880 GOTO 180
900 PRINT "LESS THAN 1 RESISTOR?"
920 PRINT "TRY AGAIN..."
940 PRINT
950 PRINT "PRESS CR TO CONTINUE..."
960 INPUT EE
970 PRINT
980 PRINT
990 GOTO 180
1000 END