|more useful options|
Elsif Clause Problemby b310 (Scribe)
|on May 10, 2004 at 15:19 UTC||Need Help??|
b310 has asked for the
wisdom of the Perl Monks concerning the following question:
I'm writing a control structure elsif clause to test various arguments and display the result that meets the argument.
My clause relates to calculating the maximum total housing payment people can afford based on the income and debt information that was provided.
The key is the down payment percentage that is going to be placed for the purchase. The options on the form are: 5%, 10%, 15%, and 20%.
Anyone with a 5%, 10%, or 15% down payment, the ratio used is 28/36. Anyone with a 20% down payment, the ratio is 33/38.
To determine the maximum total housing payment affordable, the $totalpmt variable will represent the lower of the two calculations. For example: for a 20% down payment, you will use the 33/38. If the result of 33 is lower than 38; the payment should be the calculation of 33. If the result 33 greater than 38, the payment should be the calculation of 38.
At this time, my clause works correctly for anyone who puts either a 10%, 15% and 20% down payment. If someone wants to put 5% down, the result is incorrect.
At all times, the results for 5%, 10%, and 15% should be the same since they are using the same ratio of 28/36.
Please feel free to go to my form and test it yourself. The URL is:
Here's the input data:
auto loans: 1250
Test each of the down payment percentages in the drop down box.
The result will appear in red.
The results are:
20% down = 2550
15% down = 2350
10% down = 2350
5% down = 2800 --- this is incorrect, it should be 2350 as well.
Below, is the code that I wrote to determine all this. I probably gave more information than necessary but more is better than less.
Any help you can give me in troubleshooting why 5% is not coming up with the right result is greatly appreciated.
Here's the code:
Thanks for all the help.