-
Online quote scipt
I am trying to build or find an on-line instant quote calculator
the formula I am trying to calculate is
£49 for the first 35 items
£0.85 each item thereafter
user inputs total amount of items eg 400 items
400 items - 35 = 365
365 * 0.85 = 310.25
310.25 + 49 = 359.25
Total Price £359.25
Then the total price £359.25 / 400 to give the price per item £0.89 (to two decimal places)
I've found several on-line calculator builders but nothing that can handle this sort of variables.
This script is the closest I have got but my maths is terrible and I cant seem to edit the code correctly http://www.dynamicdrive.com/forums/s...ote-calculator
-
Re: Online quote scipt
just for the record.. I am here to learn.. please just push me in the right direction, not asking for the solution here.. (just experienced abuse on stackoverflow lol)
everyones thinks it... noobs! who'd have em'
-
Re: Online quote scipt
I have this as a starting point
Math.round(400*(49+Math.max(count-35;0)*0.85)/count)/400
-
Re: Online quote scipt
You already have the math completely done in the first post. All you have to do is get the input now.
Start with a simple prompt window.
http://www.w3schools.com/jsref/met_win_prompt.asp
Now get the return and do the math.
-
Re: Online quote scipt
There's no harm in breaking the problem into simple lines of code, not least so it makes it easier for someone else to manage.
Code:
var minimum = 35,
output = 0,
input = prompt("How many items?");
if ( input<=minimum ) {
output = 49; // first 35 items are minimum £49
}
else {
output = input - minimum;
output = output * 0.85; // 85p per additional item above minimum order
output += 49;
}
alert("Total = £"+output.toFixed(2)+", Per Item = £"+(output/input).toFixed(2));
Did you deliberately want to round down though because the per item in your example is actually 0.898125 which to 2 decimal places should be 0.90?