catonthecouchproductions
asked on
Calculations coming out wrong
I am working on making a car calculator for loans, I have:
#!/usr/bin/perl
print "Content-type:text/html \n\n";
use CGI qw(:standard);
my $cost = param('cost') || '0.00';
my $payment = param('payment') || '0.00';
my $interest = param('interest') || '0.10';
my $down = param('down') || ($cost * 0.20);
my $loan = param('loan') || '5.00';
my $due = ($cost - $down) * (1 + $loan * $interest / 100);
my $month = $due / (12 * $loan);
# if nothing default values below
# print output of all entered values
my $output = <<_END_;
<b>Cost:</b> $cost <br />
<b>Payment:</b> $payment <br />
<b>Interest:</b> $interest <br />
<b>Down:</b> $down <br />
<b>Loan:</b> $loan <br />
<br /><br />
<b>Amount due each month:</b> $month
_END_
print $output;
And I am getting the wrong output for the monthly amount due. Any suggestions on what I can do to fix the output, it is coming out very large.
Link: http://elan.champlain.edu/~rcoughlin32001/carcalculator.html
Thanks,
Ryan
#!/usr/bin/perl
print "Content-type:text/html \n\n";
use CGI qw(:standard);
my $cost = param('cost') || '0.00';
my $payment = param('payment') || '0.00';
my $interest = param('interest') || '0.10';
my $down = param('down') || ($cost * 0.20);
my $loan = param('loan') || '5.00';
my $due = ($cost - $down) * (1 + $loan * $interest / 100);
my $month = $due / (12 * $loan);
# if nothing default values below
# print output of all entered values
my $output = <<_END_;
<b>Cost:</b> $cost <br />
<b>Payment:</b> $payment <br />
<b>Interest:</b> $interest <br />
<b>Down:</b> $down <br />
<b>Loan:</b> $loan <br />
<br /><br />
<b>Amount due each month:</b> $month
_END_
print $output;
And I am getting the wrong output for the monthly amount due. Any suggestions on what I can do to fix the output, it is coming out very large.
Link: http://elan.champlain.edu/~rcoughlin32001/carcalculator.html
Thanks,
Ryan
If you are getting the wrong output, what would be the correct output?
What is the relationship between $month and $loan?
What is the relationship between $month and $loan?
ASKER
This isnt an assignment one, it is being hosted on the Champlains server, I did read that you can only handle pointers for assignment questions and that is perfectly fine with me. This is an extra case study I am doing out of the book, the class is kicking my butt, haha.
I will take a look at that, what you said above.
$month is how much you are going to pay a month
$loan is how many years you want a loan for
Sorry, I should have made that clear for you guys.
Thanks,
Ryan
I will take a look at that, what you said above.
$month is how much you are going to pay a month
$loan is how many years you want a loan for
Sorry, I should have made that clear for you guys.
Thanks,
Ryan
It looks to like you're using the wrong formula.
http://en.wikipedia.org/wiki/Amortization_calculator
http://www.hughchou.org/calc/formula.html
http://en.wikipedia.org/wiki/Amortization_calculator
http://www.hughchou.org/calc/formula.html
ASKER
I am using what is given the extra case study I am doing for the heck of it. That is what they gave me for it.
Ryan
Ryan
Have a look at my last post to your other question {http://Q_22868164}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
My tip is for you to read through perlop
perldoc perlop