Qbasicnews.com
July 18, 2019, 08:42:49 PM
 Pages: [1]
 Author Topic: Year population  (Read 2316 times)
Dr_Suess
New Member

Posts: 9

 « on: May 01, 2003, 05:05:56 PM »

Im doing a program that gets the amount of years after 2003 to  output the year and population beside or after it. The population in 2003 is 350000 and it increases 5% every year.

Can you help?
Thanx
 Logged

A lie told often enough, becomes the truth"
Scrapyard
Forum Regular

Posts: 133

 « Reply #1 on: May 01, 2003, 05:35:49 PM »

Just some simple maths...

Code:

INPUT "Year you want to know the population of ",Year%

Population! = INT(350000 + 1.05 ^ (Year%-2003))

PRINT "Population in";Year%;"is";Population!
 Logged

crapyard / Cheerful Software

"All your base are belong to us"
Meg
Ancient QBer

Posts: 483

 « Reply #2 on: May 01, 2003, 06:07:55 PM »

Double check that math.

If the population in 2003 = 350,000 and increases 5% each year, then you need to multiply, not add:

Code:
input "Enter year you wish to estimate population: ", year
population = 350000 * 1.05 ^ (year - 2003)
print "Population will be: "+ STR\$(population)

*peace*

Meg.
 Logged
toonski84
__/--\__

Posts: 2567

 « Reply #3 on: May 01, 2003, 06:13:47 PM »

I think the formula goes:

f(x) = c*e^(kt)

where e is log(1), c is the initial population, k is .05 and t is the number of years.  some dumb algebra 2 formula i keep forgetting...  i think the way they give might work too, i dont know (i was never much of a mathematician).
 Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Scrapyard
Forum Regular

Posts: 133

 « Reply #4 on: May 02, 2003, 04:05:25 AM »

Woops my mistake  :wink:
 Logged

crapyard / Cheerful Software

"All your base are belong to us"
oracle
*/-\*

Posts: 3652

 « Reply #5 on: May 02, 2003, 04:11:47 AM »

That's just the compound interest formula... nothing hard about it (but toonski your method is just weird and confusing)
 Logged

toonski84
__/--\__

Posts: 2567

 « Reply #6 on: May 02, 2003, 08:41:13 AM »

yeah, it's used for interest problems, but my calc book uses it mostly for population problems, and pretty much any kind of exponential problem.
 Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Agamemnus
x/ \z

Posts: 3491

 « Reply #7 on: May 02, 2003, 02:39:04 PM »

Toonski, e?
Depends on if it is a continual growth or not.
 Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
 Pages: [1]