BAH! I must be mentally retarded with math

K.I.L.E.R

Retarded moron
Veteran
attachment.php


Oh why can't I get SIMPLE math right? :rolleyes:

Code:
'PROCESSING:

Do While intCounter <= 10
curInterest = curInterestRate * curBalance
curBalance = curBalance + curInterest
curBalance = (curBalance - (curMonthlyRepayment * 12)) - curDeposit
lstAnswer.AddItem "End of Year " & intCounter & " " & FormatCurrency(curBalance)
intCounter = intCounter + 1
Loop

If curBalance = 0 Then
lstAnswer.AddItem "You will pay this off in " & intCounter & " Years"
End If

If curBalance > 0 And intCounter = 10 Then
MsgBox "You are geting ripped", vbExclamation, "RIP OFF ALERT!"
End If

The code isn't the problem. It's my stupid math abilities.
 
I would say the code is your problem.

-Shouldn't you loop until it's paid of, not a fixed amount of times?

-Why check if curBalance is 0? The chance of over hitting a balance of excactly 0 is very slim. You should check if it is less or equal.

-The last IF will always fail; intCounter is 11 when you exit the loop.

But I don't know what you're trying to do, so this might not be valid points...
 
Thowllly said:
I would say the code is your problem.

-Shouldn't you loop until it's paid of, not a fixed amount of times?

-Why check if curBalance is 0? The chance of over hitting a balance of excactly 0 is very slim. You should check if it is less or equal.

-The last IF will always fail; intCounter is 11 when you exit the loop.

But I don't know what you're trying to do, so this might not be valid points...

-Nah, has to be a fixed amount.

-Funny thing it works either way but I have done the changes anyway as you are right

-I had this fixed after my post

Thanks for the help. Nice to know it's the code rather then my math skills. :)
For a second there I thought I may be mentally ill. :)

One other question, why the hell are my numbers smaller then much larger near the end?

Interest is calculated on the balance outstanding at beginning of each year and credited to the loan amount to be repaid at this time. - I assume I have this right?

OH CRAP! I look over my code carefully and it is the calculations that I keep looping. I can't keep taking off the deposit every year. :doh:
 
K.I.L.E.R said:
Thanks for the help. Nice to know it's the code rather then my math skills. :)
For a second there I thought I may be mentally ill. :)

One other question, why the hell are my numbers smaller then much larger near the end?
I think those larger number towards the end are actually negative numbers. Notice the ( ) around them.
Interest is calculated on the balance outstanding at beginning of each year and credited to the loan amount to be repaid at this time. - I assume I have this right?
I'm not sure. I thought the interest was calculated every month for loans, but I really don't know...
OH CRAP! I look over my code carefully and it is the calculations that I keep looping. I can't keep taking off the deposit every year. :doh:
I thought it was strange you were doing that. It was one of the reasons for my "I don't know what you're trying to do" comment. :)
 
Better tell you. :)

I am doing a business calculator.

Some dude wants to pay off a car in 10 years or under.

If it's over 10 years then a message must be dispalyed saying it's a bad deal.

If the car is paid off in 5 years then the loop must stop and a message must be displayed it will be paid off in 5 years.

Normally I would not have a problem with something so simple. Makes me wander what is going on inside my head. :cry:
 
Humus said:
Thowllly said:
I would say the code is your problem.

Indeed. Anything done in VB is doomed to fail. ;)

I found VB much harder to work with than C/C++. VB has a bloated feel to it.

Basic said:
If you want to loop a fixed amount of years, you'll need to explain why.

Oh wait, I wasn't thinking properly. My thoughts are all over the place.
Yes, I have to loop until it is paid off but if it takes more than 10 years it must stop at 10 years and dispaly a message.
 
Humus said:
Can't this problem be solved with a simple formula anyway?

If my former physics teacher heard you say that... ;)

That's what I thought. Doesn't seem to be the case for me. Then again I tend to complicate things.
 
Thanks guys.

I have nearly got it.

close.JPG


Now all I have to do is get rid of the last line (negative number).

I also have to use the isnumeric function to make sure all the boxes include only numbers and then I am done. :)
 
First a general comment about small calculations like this.
Excel (and other spreadsheets) are realy nice. They provide an easy interface for simple things like this, and you have usually lots of spare cells if you want to do a calculation on your own beside. You'll get simple recalculations of values without any retyping or copy&paste.

I never use a calculator if I'm sitting in front of a computer, unless I need to do base convertions, that's the only lacking part in Excel compared to a calc.

K.I.L.E.R:
I looked at your numbers, and there's something strange in there. I can't see any way to get to your first number. The rest of the numbers (year 2...) are at least consistent with the way you calculated, but the first isn't.

Russ:
[Edit]
Removed stuff that I stand by, but isn't nice to say to a whole bunch of people (I don't think anyone here is at target though). Stuff that I wouldn't dream of saying if I knew there was an economist nearby.

I'll cut it down to:
I don't like those formulas. But I wouldn't be suprised if they are used. They are a hack around the incorrect belief that if the yearly interest rate is X, then the monthly should be X/12.
 
Code:
'check if guy is older than 25
If intAge < 25 Then
curBalance = curBalance + 1000
lblLoan.Visible = True
End If

'PROCESSING:
curInterest = curInterestRate * curBalance
curBalance = curBalance + curInterest
curBalance = (curBalance - (curMonthlyRepayment * 12)) - curDeposit

lstAnswer.AddItem "End of Year 1 " & FormatCurrency(curBalance)

intCounter = 2

Do While curBalance > 0

curInterest = curInterestRate * curBalance
curBalance = curBalance + curInterest
curBalance = (curBalance - (curMonthlyRepayment * 12))

If curBalance < 0 Then
lstAnswer.AddItem "You will pay this off in " & intCounter & " Years"
End If

lstAnswer.AddItem "End of Year " & intCounter & " " & FormatCurrency(curBalance)

intCounter = intCounter + 1
Loop

If curBalance > 0 And intCounter = 10 Then
MsgBox "You are geting ripped", vbExclamation, "RIP OFF ALERT!"
End If

End Sub

That's my calc code.

My math:
First formula:
curInterest = curInterestRate * curBalance
curBalance = curBalance + curInterest
curBalance = (curBalance - (curMonthlyRepayment * 12)) - curDeposit

2nd formula:
curInterest = curInterestRate * curBalance
curBalance = curBalance + curInterest
curBalance = (curBalance - (curMonthlyRepayment * 12))

BTW: WTF is up with all these overflows?
 
He has to pay an extra $1000 for the car if he's under 25 years old! Is that common practice?

Is it normal to pay one years interest on the deposit? You do.

I can't comment on wether the "MonthlyRepayment*12" part is correct. It's not logical, but it might be the way the person making you pay calculates it, and then that's the way it is.
 
Now only 1 thing remains. How do I get rid of the negative number after it displays the pay off message?

BTW: Why does VB have so many overflows? I do the same equations with the values that gave me overflows in VB in C++ and it works fine. VB must really be crap. :LOL:

Basic: That's the way it says I have to do it on the worksheet. Whacky as it is but who am I to argue with the teacher? (I argue anyway) :LOL:
 
RussSchultz said:
Interest is calculated on a daily basis.

At least in all the loans I've dealt with.

No that very much depends on the financial institution. Some definitely use monthly calcs (for your 'convenience' :) (oh and the profit of the bank))
 
Simon:
What realy gets me going is that if economists had the basic nowledge in math that is needed for their work(*), it wouldn't matter if they made the calculations per year, month, day or second.

(*) This could be a mix with some that actually know the math, but realize they can use it too fool customers instead.
 
It's completely fixed. I just needed to place an if statement on the display and change my formula into 2 lines. Take the balance from the car price before any other calculation.
 
Basic said:
I'll cut it down to:
I don't like those formulas. But I wouldn't be suprised if they are used. They are a hack around the incorrect belief that if the yearly interest rate is X, then the monthly should be X/12.
I don't understand your point. If the interest is compounded monthly, then you would take the annual interest rate and divide it by 12 to get the monthly rate. In fact, if you have an interest rate of r compounded n times per year, then the interest per period is r/n. Note that this refers to the interest rate, not the APR.

If I've missed your point, please clarify.
 
Back
Top