Category : A Collection of Games for DOS and Windows
Archive   : DBD.ZIP
Filename : DBD.BAS

 
Output of file : DBD.BAS contained in archive : DBD.ZIP

1 ' SAVE "DBD",a
2 ' ----------------------------------------------------------------------------
3 ' Days Between Dates was originally written as a sub-routine for a program
4 ' to determine random payments on a loan and calculate daily interest due at
5 ' the time of payment. Dates are picked up from variables in the loan file
6 ' rather than on direct entry. However, putting it into this program makes
7 ' the routine available for other purposes, and the source code can be
8 ' can be modified to suit your own needs. Enjoy! - PROF~~~~~ [BDB647]
9 ' ----------------------------------------------------------------------------
10 DIM A(112),M$(12),D$(7)
20 FOR I=1 TO 12:READ A(I):NEXT
30 FOR I=101 TO 112:READ A(I):NEXT
40 FOR I=1 TO 12:READ M$(I):NEXT
50 FOR I=1 TO 7:READ D$(I):NEXT
100 CLS
110 PRINT:PRINT CHR$(201);STRING$(77,CHR$(205));CHR$(187)
120 PRINT CHR$(186);" CALCULATE DAYS BETWEEN TWO CALENDAR DATES - Useful in Interest Calculations ";CHR$(186);
130 PRINT:PRINT CHR$(200);STRING$(77,CHR$(205));CHR$(188)
140 PRINT:PRINT
150 INPUT " >> ENTER LATEST DATE as mmddyy or for TODAY: ",LATEST$
160 IF LEN(LATEST$)=0 THEN LATEST$=LEFT$(DATE$,2)+MID$(DATE$,4,2)+RIGHT$(DATE$,2)
170 A=VAL(LEFT$(LATEST$,2)):B=VAL(MID$(LATEST$,3,2)):C=1900+VAL(RIGHT$(LATEST$,2)):M=A:D=B:Y=C
180 GOSUB 400
190 Z=T
200 PRINT:INPUT " >> ENTER EARLIEST DATE as mmddyy: ",EARLIEST$
210 E=VAL(LEFT$(EARLIEST$,2)):F=VAL(MID$(EARLIEST$,3,2)):G=1900+VAL(RIGHT$(EARLIEST$,2)):M=E:D=F:Y=G
220 GOSUB 400
230 V=T-Z
240 V=ABS(V)
250 PRINT:PRINT
260 PRINT " * LATEST DATE -- ";:U=V+N:U=U-7*INT(U/7)
270 Q=U+1:IF U=7 THEN U=0
280 GOSUB 590:P=A:PRINT ", ";:GOSUB 580:PRINT B;C
290 PRINT:PRINT " * EARLEST DATE -- ";:Q=N+1:GOSUB 590:PRINT ", ";
300 P=E:GOSUB 580:PRINT F;G
310 PRINT:PRINT
320 PRINT " A DIFFERENCE OF ";V;" DAYS"
330 PRINT " (";INT((V/365)*100)/100;" YEARS)"
340 PRINT:PRINT
350 PRINT " >> Do you want to try another date (Y/N)? ";:ANS$=INKEY$
360 WHILE ANS$<>"Y" AND ANS$<>"y" AND ANS$<>"N" AND ANS$<>"n" AND ANS$<>CHR$(13):ANS$=INKEY$:WEND
370 IF ANS$="Y" OR ANS$="y" THEN 100
380 CLS:END
390 ' - Sub-routines & Data Statements
400 H=Y-1800
410 I=INT(H/4)
420 J=INT(I/25)
430 L=INT((H+200)/400)
440 K=0
450 IF I*4<>H THEN 490
460 IF J*100<>H THEN 490
470 IF L*400-200<>H THEN 490
480 K=1
490 T=365*H+I-J+L-K
500 T=T+A(M)+D-1
510 IF M<3 THEN 530
520 T=T+K
530 IF INT(H/4)<>H/4 THEN 560
540 IF M>2 THEN 560
550 T=T-1
560 N=T-7*INT(T/7)
570 RETURN
580 PRINT M$(P);:RETURN
590 PRINT D$(Q);:RETURN
600 DATA 0,31,59,90,120,151,181,212,243,273,304,334
610 DATA 31,28,31,30,31,30,31,31,30,31,30,31
620 DATA "JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER",DECEMBER"
630 DATA "WEDNESDAY","THURSDAY","FRIDAY","SATURDAY","SUNDAY","MONDAY","TUESDAY"