I'm currently doing a school assignment. The aim is to basically find out the amount of animals there are remaining when a certain percentage is wiped out, you then enter the amount of years that the species of animal is declining.
I have 3 textboxes, a calculate button and a label to display my answer.
I'm not 100% what equation to use.
My equation
1000 * (1 - 0.50) ^ 2
1000 animals, they are reducing 50% every year for two years.
The code:
It doesn't seem to work, I put 1000, 0.5 and 2 into the textbox fields and press calculate, my answer is 1000. It's stuffed up.
I tried again and put 1000, 10 and 2 and it came up with 81000 as the answer.
I have 3 textboxes, a calculate button and a label to display my answer.
I'm not 100% what equation to use.
My equation
1000 * (1 - 0.50) ^ 2
1000 animals, they are reducing 50% every year for two years.
The code:
VB.NET:
[COLOR=#333333]Code:
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim animals, rate, year as Integer
animals = txtAnimals.Text
rate = txtRate.Text
year = txtYear.Text
lblDisplayNum.Text = animals * (1 - rate) ^ year
End Sub[/COLOR]
It doesn't seem to work, I put 1000, 0.5 and 2 into the textbox fields and press calculate, my answer is 1000. It's stuffed up.
I tried again and put 1000, 10 and 2 and it came up with 81000 as the answer.