and they all got sick :( - a small epidemiology program

General FreeBASIC programming questions.
ron77
Posts: 22
Joined: Feb 21, 2019 19:24
Location: Israel

and they all got sick :( - a small epidemiology program

Postby ron77 » Apr 01, 2020 10:27

hi all.

here is another small code converted from qb64
an epidemiology test or experiment over corona virus outbreak...

it very simple code
1. choose population size
2. each day passes infections doubles
3. after 1000 infections (sickness cases) people start to die by 3.4 % mortality each day
4. when infections reaches half or so of population program stops.

i guess i could have called it sadly "and they all got sick and... died..." but that's too simplistic and pessimistic and terrible :(
if i could i would write a program that will kick this corona virus a** and make it go away...

p.s. - one thing i found i tried to use unsigned integer 64 or ulongint but it wouldn't recognized so i used the suffix "ull" and that did the trick but i wonder why is it a bug in the compiler? (freebasic 32-bit 1.07 i think) i tried to finf the 64-bit compiler for freebasic but couldn't any one have an idea?...

Code: Select all

#Lang"qb"
'_TITLE "CORONA VIRUS"
Screen 0
'DIM Shared As ULongInt
Dim Shared INFECTIONSull 'As unsigned Integer
Dim Shared DEATHSull 'As unsigned Integer
Dim Shared POPull 'As unsigned Integer
Dim Shared DAYS AS Integer
INFECTIONSull = 1




SUB cp (row, s$)
    LOCATE row, (80 - LEN(s$)) / 2: PRINT s$
END SUB

SUB opening
    cp 2, "CORONA VIRUS"
    cp 4, "A EXPERINENT IN EPIDEMIOLOGY"
    cp 6, "PRESS ANY KEY TO CONTINUE"
    DO
    LOOP UNTIL INKEY$ <> ""
END SUB

SUB corona
    CLS
    LOCATE 5, 5
    INPUT "ENTER POPULATION'S NUMBER: ", POPull

    DO
        CLS
        PRINT "DAY: " + STR$(DAYS)
        PRINT "INFECTIONS: " + STR$(int(INFECTIONSull))
        PRINT "DEATHS: " + STR$(Int(DEATHSull))
        PRINT "POPULATION: " + STR$(Int(POPull - DEATHSull))
        Sleep 1
        DAYS = DAYS + 1
        INFECTIONSull = INFECTIONSull * 2
        IF INFECTIONSull > 1000 THEN DEATHSull = INFECTIONSull * 34 / 1000

    LOOP UNTIL INFECTIONSull > POPull
   Print "press any key..."
   sleep
END SUB

opening
corona
paul doe
Posts: 1175
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: and they all got sick :( - a small epidemiology program

Postby paul doe » Apr 01, 2020 12:00

ron77 wrote:...
p.s. - one thing i found i tried to use unsigned integer 64 or ulongint but it wouldn't recognized so i used the suffix "ull" and that did the trick but i wonder why is it a bug in the compiler? (freebasic 32-bit 1.07 i think) i tried to finf the 64-bit compiler for freebasic but couldn't any one have an idea?...

Look at the FreeBasic Manual page for ulongint, under 'Dialect differences'. You need to use an alias:

Code: Select all

#lang "qb"

dim as __ulongint _
  foo

foo = 4

? foo

sleep()

Return to “General”

Who is online

Users browsing this forum: No registered users and 3 guests