home *** CD-ROM | disk | FTP | other *** search
/ The CIA World Factbook 1992 / k3bimage.iso / sel / 04 / 0074 / resistor.bas next >
Encoding:
BASIC Source File  |  1991-12-02  |  2.3 KB  |  80 lines

  1. 1 REM RESISTOR COLOR CODE INTERPRETATION
  2. 2 REM
  3. 3 REM IBM PC PROGRAMS IN
  4. 4 REM SCIENCE AND ENGINEERING
  5. 5 REM
  6. 6 REM BY JULES H. GILDER
  7. 7 REM & SCOTT p. GILDER
  8. 8 REM
  9. 9 REM HAYDEN BOOK COMPANY
  10. 10 REM**************************
  11. 15 CLS:SCREEN 2
  12. 20 T$="RESISTOR COLOR CODE"
  13. 30 L=LEN(T$)
  14. 40 PRINT TAB(INT((80-L)/2+.5));T$
  15. 50 PRINT:PRINT:PRINT
  16. 60 DIM E$(10)
  17. 70 PRINT "This program interprets the resistor color code.  You must enter the color"
  18. 80 PRINT "of each band and the program will tell you what the value of the resistor is."
  19. 90 RESTORE
  20. 100 PRINT:PRINT "Possible colors are:":PRINT
  21. 110 FOR X=0 TO 9
  22. 120 READ E$(X)
  23. 130 PRINT E$(X)
  24. 140 NEXT X
  25. 150 PRINT:PRINT
  26. 160 INPUT "Enter color of first band";A$
  27. 170 U$=A$:GOSUB 600:A$=U$
  28. 180 IF A$="gray" THEN A$="grey"
  29. 190 PRINT:INPUT "Enter color of second band";B$
  30. 200 U$=B$:GOSUB 600:B$=U$
  31. 210 IF B$="gray" THEN B$="grey"
  32. 220 PRINT:INPUT "Enter color of third band";C$
  33. 230 U$=C$:GOSUB 600:C$=U$
  34. 240 IF C$="gray" THEN C$="grey"
  35. 250 PRINT:PRINT:INPUT "Enter color of fourth band (gold, silver, or none)";D$
  36. 260 U$=D$:GOSUB 600:D$=U$
  37. 270 RESTORE
  38. 280 FOR X=0 TO 9
  39. 290 READ E$(X)
  40. 300 IF A$=E$(X) THEN Q=X
  41. 310 IF B$=E$(X) THEN R=X
  42. 320 IF C$=E$(X) THEN S=X
  43. 330 IF C$="white" OR C$="gold" THEN S=-1
  44. 340 IF C$="grey" OR C$="silver" THEN S=-2
  45. 350 IF D$="gold" THEN T=5
  46. 360 IF D$="silver" THEN T=10
  47. 370 IF D$="none" THEN T=20
  48. 380 NEXT X
  49. 390 GOSUB 460
  50. 400 PRINT:PRINT:PRINT
  51. 410 PRINT "Resistor value is";RE;" ";G$
  52. 420 PRINT
  53. 430 PRINT "It has a tolerance of";T;"percent"
  54. 440 DATA "black","brown","red","orange","yellow","green","blue","purple","grey","white"
  55. 450 GOTO 550
  56. 460 RR=10*Q+R
  57. 470 IF S<2 THEN G$="Ohms"
  58. 480 IF S=>2 AND S<5 THEN G$="Kilohms"
  59. 490 IF S=>2 AND S<5 THEN S=S-3
  60. 500 IF S=>5 THEN G$="Megohms"
  61. 510 IF S=>5 THEN S=S-6
  62. 520 RE=INT(RR+.5)*INT(10^S+.5*S)
  63. 530 RE=INT(10*RR*10^S+.5)/10
  64. 540 RETURN
  65. 550 PRINT:PRINT:PRINT
  66. 560 PRINT "Do you have another resistor (Y or N)"
  67. 570 AN$=INKEY$:IF AN$="" THEN 570
  68. 575 IF AN$="y" OR AN$="Y" THEN RUN
  69. 580 END
  70. 590 REM ROUTINE TO CONVERT UPPERCASE TO LOWERCASE
  71. 600 U2$=""
  72. 610 FOR U=1 TO LEN (U$)
  73. 620 U1$=MID$(U$,U,1)
  74. 630 U1=ASC(U1$)
  75. 640 IF U1<91 THEN U1=U1+32
  76. 650 U2$=U2$+CHR$(U1)
  77. 660 NEXT U
  78. 670 U$=U2$
  79. 680 RETURN
  80. {╔vÉn ╜ 0░φΓφ╠nδ0@║n┼S╨∞.╪╗╩Ö£╜á