PDA

View Full Version : Math question. Haaaalp



PrivateParts
Jan 2nd, 2009, 08:36 PM
Im trying to figure out the math for programming question but my brain isnt working.

Negotiating a consumer loan is not always straightforward. One form of loan is the discount
installment loan, which works as follows. Suppose a loan has a face value of $1,000,
the interest rate is 15%, and the duration is 18 months. The interest is computed by multiplying
the face value of $1,000 by 0.15, yielding $150. That figure is then multiplied by
the loan period of 1.5 years to yield $225 as the total interest owed. That amount is immediately
deducted from the face value, leaving the consumer with only $775. Repayment is
made in equal monthly installments based on the face value. So the monthly loan payment
will be $1,000 divided by 18, which is $55.56.

So
1000 x (.15 x 1.5) = 225
1000 - 225 = 775
Thats simple

This method of calculation may not be too
bad if the consumer needs $775 dollars, but the calculation is a bit more complicated if the
consumer needs $1,000.

Write a program that will take three inputs: the amount the consumer
needs to receive, the interest rate, and the duration of the loan in months. The program
should then calculate the face value required.



Ok, lets just say the consumer needs 775 dollars instead of 1000 right now. The consumer would need a face value of 1000 bucks.

I need to figure out how to get 1000 from the three inputs:
needs to received = 775
interest rate = 15%
duration = 18 months (1.5 years)


I cant figure out how to get 1000 bucks in face value out of these three inputs. Or 225 out of them.



haaaalp. This isnt part of any assigment. Its just making me crazy not being able to figure it out after reading and trying it.

Curse you alcohol and your many days of intoxication!

Koobazaur
Jan 2nd, 2009, 09:33 PM
Math is fun.

Look at your initial equation:

1000 x (.15 x 1.5) = 225
1000 - 225 = 775


now plug in the variables instead of exactly values

F * (i * d ) = x
F - x = n

which can be assembled into:

F - [F * (i * d )] = n

Where:

F - face value
i - interest (decimal)
d - duration (years)
n - needed

now we provide i, d and n and want to get F. so simply, solve for F

F - [F * (i * d )] = n
F * [ 1 - (i * d) ] = n

F = n / [ 1 - (i * d) ]



shazing

PrivateParts
Jan 2nd, 2009, 09:53 PM
Terrorismmmmmm


My math is rusty, i get everything except how did the F become a 1. factored or something?

Maxey
Jan 2nd, 2009, 10:27 PM
My head assplodes.

Koobazaur
Jan 2nd, 2009, 11:52 PM
Terrorismmmmmm


My math is rusty, i get everything except how did the F become a 1. factored or something?

Yup, I factored it out. It's just like:

(a - ab) = a(1 - b)

PrivateParts
Jan 3rd, 2009, 12:04 AM
Ah, the F * was throwing me off. Since its still * even without the symbol there.

Anyway thanks.


I dont start classes till monday. Maybe ill do this program aswell for the lab as bonus marks.
Though most likely ill just end up waiting until the day before my other work is due.

Koobazaur
Jan 3rd, 2009, 12:40 AM
That is easy, it's like 10 lines of code. What language are you writing it in?

PrivateParts
Jan 3rd, 2009, 12:41 AM
C++

Koobazaur
Jan 3rd, 2009, 01:18 AM
#include <iostream>

using namespace std;

void main()
{
float needed, interest, yourMom;
cout << "Bitch give me your need: ";
cin >> needed;
cout << "Interest (as decimal): ";
cin >> interest;
cout << "Duration (years): ";
cin >> yourMom;
cout.setf(ios::fixed,ios::floatfield);
cout.precision(2);
cout << "Your face value is $" << needed / ( 1 - interest * yourMom ) << ". Also cocks. " << endl;

system("PAUSE");

return;
}


note this does not check if the input is indeed numeric and will fail if it's not.

Also, I want 10% of all your earning from this point on

Leomhann
Jan 6th, 2009, 06:17 PM
I think I just pulled an exorcist with the head spinning

Sonic
Jan 6th, 2009, 08:54 PM
As a finance person, this doesn't look right. If this is for the art of programming, fine... but as a finance question it's f-ed in the A. Is this exactly as the question warrants, or did you make anything up?

PrivateParts
Jan 21st, 2009, 05:27 AM
Its a copy and paste (pretty much) out of a pdf i have of the book absolute C++ (2nd edition)