|
-
May 15th, 2011, 12:34 PM
#4
Thread Starter
Hyperactive Member
Re: Help with maths in javascript
As you can see i've reversed the code, using the fare calculator with a distance of 1.08 miles now correctly displays a price of £2.34. However when using a larger distance such as 195.14 miles its displays a price of £351.65, when it should be £226.26
thanks chris1990
Code:
if (distance <= 300); // less than 300 Mile
{firstMile = 3.00; // FM £3.00
TrafficP = 1.00;// add 10% for traffic
pricepMile = 1.10;}// PPM £1.00
if (distance <= 175); // less than 150 Mile
{firstMile = 3.00; // FM £3.00
TrafficP = 1.00;// add 10% for traffic
pricepMile = 1.15;}// PPM £1.10
if (distance <= 100); // less than 100 Mile
{firstMile = 3.00; // FM £3.00
TrafficP = 1.00;// add 10% for traffic
pricepMile = 1.20;}// PPM £1.20
if (distance <= 50); // less than 50 Mile
{firstMile = 3.00; // FM £3.00
TrafficP = 1.00;// add 10% for traffic
pricepMile = 1.30;}// PPM £1.30
if (distance <= 30); //less than 30 Mile
{firstMile = 3.00; // FM £2.50
TrafficP = 1.00;// add 15% for traffic
pricepMile = 1.40};// PPM £1.40
if (distance <= 15); // less than 15 Mile
{firstMile = 2.20; // FM £2.20
TrafficP = 1.00;// add 00% for traffic
pricepMile = 1.80};// PPM £1.80 - standard tariff
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|