I tried to write this code out, I dont want the answer I just want someone to explain to me what I am missing and doing wrong.

Suppose the population of a certain country was 125,000 at the beginning of the year 1995. The population is growing at a rate of 4.3% per year. Write a program that determines in what year the population will reach or exceed 200,000.


Private Sub btnDisplay_Click(...)Handles_
btnDisplay.Click
Dim number As Integer
Dim count As Integer
number = 125000
count = 12 months
Do
number = number * 4.3
count = count + 1
Loop Until count = 200000
lstOutput.Items.Add(number)
End Sub

Recommended Answers

All 2 Replies

number = number * 4.3

i think that's wrong , you need to add 125,000 to the population grouth each year

number=number+(number*4.3)
Loop Until
count = 200000

other thing why you stop looping untill count=200 000 ?i think you mean number not count

4.3 percent is .043 so you are making it 4 times the size. i.e. 100 * 4 = 400 sould be 100 * .04 = 4

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.