'=========================================================================== ' Subject: CALCULATE WIND CHILL Date: 10/95 (00:00) ' Author: Steve Horstmeyer Code: QB, QBasic, PDS ' Origin: Internet Packet: ALGOR.ABC '=========================================================================== 'BASIC LANGUAGE PROGRAM TO CALCULATE WIND CHILL BASED ON SIPLE FORMULA ' WEATHERWISE MAGAZINE OCTOBER/NOVEMBER 1995 BY STEVE HORSTMEYER 'RUNS UNDER DOS v5.x & V6.x QBASIC, OR QUICKBASIC OR QUICKBASIC EXTENDED. 'THIS PROGRAM WILL NOT RUN UNDER OLDER VERSIONS OF GWBASIC, BASIC OR BASICA 'FROM DOS V4.X OR EARLIER. LINE NUMBERS ARE NOT REQUIRED IN QBASIC, WHERE 'NEEDED A LINE CAN HAVE A LABEL LIKE CHOOSEMODE: ONEWCHILL: AND TABLE: BELOW. DIM WTABLE(11, 13), TEMPS(13), WIND(11) CLS 'DEF FNWCT defines a function that calculates wind chill using the Siple 'formula. Statement IF VEL<=4 sets wind chill to temp if wind is <=4mph. 'to de-activate add 'to make lie a comment, result is rounded DEF FNWCT (VEL, TMP) WC = .0817 * (3.71 * (VEL ^ .5) + 5.81 - .25 * VEL) * (TMP - 91.4) + 91.4 IF VEL <= 4 THEN WC = TMP FNWCT = CINT(WC) END DEF CLS LOCATE 2, 9: COLOR 14, 0: PRINT "BASIC LANGUAGE PROGRAM TO CALCULATE WIND CHILL USING SIPLE FORMULA" LOCATE 5, 20: PRINT "REQUIRES MS-DOS (V5.X OR HIGHER) QBASIC " LOCATE 6, 21: PRINT "OR QUICKBASIC OR QUICK BASIC EXTENDED" LOCATE 7, 27: PRINT "WEATHERWISE NOVEMBER 1995" LOCATE 8, 30: PRINT "BY STEVE HORSTMEYER" LOCATE 10, 34: COLOR 31, 0: PRINT "PRESS ANY KEY" WHILE INKEY$ = "": WEND '*****determine if user wants a single value or table***** CHOOSEMODE: CLS : COLOR 7, 0 LOCATE 3, 1: PRINT "TO CALCULATE A SINGLE VALUE PRESS S " LOCATE 5, 1: PRINT "TO DISPLAY A TABLE PRESS T " INPUT MODE$: MODE$ = UCASE$(MODE$) SELECT CASE MODE$ CASE "S" GOSUB ONEWCHILL CASE "T" GOSUB TABLE CASE ELSE GOTO CHOOSEMODE END SELECT END '*******************SUBROUTINES***************** '*****find single windchill***** ONEWCHILL: CLS : COLOR 7, 0 LOCATE 2, 1: INPUT "ENTER TEMPERATURE (F) "; T: T = CINT(T) LOCATE 4, 1: INPUT "ENTER WIND VELOCITY (MPH) "; V: V = CINT(V) IF V < 0 THEN CLS : LOCATE 1, 1: COLOR 30, 0 PRINT "WIND VELOCITY MUST BE POSITIVE" COLOR 30, 0 PRINT "TO START AGAIN PRESS ANY KEY" WHILE INKEY$ = "": WEND GOTO ONEWCHILL END IF CLS LOCATE 2, 1: PRINT "WIND CHILL BASED ON SIPLE FORMULA" LOCATE 4, 1: PRINT "TEMPERATURE "; T; "F AND" LOCATE 6, 1: PRINT "WIND VELOCITY "; V; "MPH" COLOR 9, 0: LOCATE 8, 1: PRINT "WIND CHILL = "; FNWCT(V, T); " F" REPEAT: LOCATE 12, 1: COLOR 14, 0: INPUT " ANOTHER S, RESTART R OR EXIT E "; AGAIN$ AGAIN$ = UCASE$(AGAIN$) SELECT CASE AGAIN$ CASE "S" GOTO ONEWCHILL CASE "R" GOTO CHOOSEMODE CASE "E" END CASE ELSE GOTO REPEAT END SELECT RETURN: '*****end of subroutine to calculate single value***** '*****calculate and display table***** TABLE: CLS LOCATE 3, 1: PRINT "ENTER MINIMUM TEMPERATURE (FOR >80 PROGRAM DEFAULTS TO 80)" LOCATE 5, 1: PRINT "TABLE WILL BE CALCULATED FOR 5 DEGREE INCREMENTS" LOCATE 7, 1: PRINT "WIND SPEEDS ARE FIXED FROM ZERO TO 45 MPH IN 5 MPH INCREMENTS" LOCATE 9, 1: COLOR 30, 0: PRINT "PRESS ANY KEY TO CONTINUE" WHILE INKEY$ = "": WEND: COLOR 14, 0 LOCATE 12, 1: INPUT "ENTER LOWEST TEMPERATURE F"; MNTEMP MNTEMP = CINT(MNTEMP): COLOR 7, 0 IF MNTEMP > 80 THEN MNTEMP = 80 FOR V = 0 TO 50 STEP 5 WINDEX = V / 5: WIND(WINDEX) = V: TINDEX = 0 FOR T = MNTEMP TO MNTEMP + 60 STEP 5 TEMPS(TINDEX) = T WTABLE(WINDEX, TINDEX) = FNWCT(V, T): TINDEX = TINDEX + 1 NEXT T: NEXT V '*****display table on screen***** WRITETABLE: CLS : COLOR 14, 0 LOCATE 2, 2: PRINT "WIND": LOCATE 2, 33: PRINT "AIR TEMPERATURE" FOR I = 0 TO 12 PRINT TAB(10 + I * 5); TEMPS(I); NEXT I LOCATE 3, 3: PRINT "VEL": COLOR 7, 0 FOR I = 2 TO 4 LOCATE I, 9: PRINT "|" NEXT I LOCATE 4, 10: PRINT STRING$(70, "="): LOCATE 3, 10 FOR ROW = 0 TO 9 LOCATE 2 * ROW + 5, 4 COLOR 14, 0: PRINT WIND(ROW) COLOR 7, 0: LOCATE 2 * ROW + 5, 9: PRINT "|" FOR COLUMN = 0 TO 12: COLOR 15, 0 SELECT CASE WTABLE(ROW, COLUMN) CASE IS > TEMPS(COLUMN) IF WTABLE(ROW, COLUMN) > 120 THEN COLOR 4, 0 ELSE COLOR 12, 0 END IF CASE 11 TO 32 COLOR 1, 0 CASE -20 TO 10 COLOR 9, 0 CASE -49 TO -21 COLOR 13, 0 CASE IS <= -50 COLOR 29, 0 END SELECT LOCATE 2 * ROW + 5, 10 + COLUMN * 5: PRINT WTABLE(ROW, COLUMN) LOCATE 2 * ROW + 6, 9: COLOR 7, 0: PRINT "|"; NEXT COLUMN: NEXT ROW COLOR 14, 0 LOCATE 25, 1: INPUT "PRESS TO RESTART PRESS TO EXIT "; RERUN$ RERUN$ = UCASE$(RERUN$) SELECT CASE RERUN$ CASE "E" CLS END CASE "R" GOTO CHOOSEMODE CASE ELSE GOTO WRITETABLE END SELECT RETURN: '*****end of table subroutine*****