![Old](images/statusicon/post_old.gif)
25th March 2016, 08:25 PM
|
Member
|
|
Join Date: Sep 2011
Posts: 1,490
|
|
Java version:
public static double convertPrice(double price, int change)****
double priceNew = price;
if (price >= 1.01 && price <= 1.9999)****
priceNew = roundTwoDecimals(price+((0.005*change)+(change*0.0 00001)));
****
if(price >= 2.00 && price <= 2.9999)****
priceNew = (roundTwoDecimals((price/2)+((0.005*change)+(change*0.000001)))) * 2 ;
****
if (price >= 3.00 && price<= 3.9999)****
priceNew = (roundTwoDecimals((price/5)+((0.005*change)+(change*0.000001)))) * 5;
****
if (price >= 4.00 && price<= 5.9999)****
priceNew = (roundTwoDecimals((price/10)+((0.005*change)+(change*0.000001)))) * 10; //0.1
****
if (price >= 6.00 && price<= 9.9999)****
priceNew = (roundTwoDecimals((price/20)+((0.005*change)+(change*0.000001)))) * 20; //0.2
****
if (price >= 10.00 && price<= 20.000)****
priceNew = (roundTwoDecimals((price/50)+((0.005*change)+(change*0.000001)))) * 50; //0.5
****
if (price >= 20.00 && price<= 29.9999)****
priceNew = (roundTwoDecimals((price/100)+((0.005*change)+(change*0.000001))) ) * 100; //1
****
if (price >= 30.00 && price<= 49.9999)****
priceNew = (roundTwoDecimals((price/200)+((0.005*change)+(change*0.000001))) ) * 200; //2
****
if (price >= 50.00 && price<= 99.9999)****
priceNew = (roundTwoDecimals((price/500)+((0.005*change)+(change*0.000001))) ) * 500; //5
****
if (price >= 100.00 && price<= 1000)****
priceNew = (roundTwoDecimals((price/1000)+((0.005*change)+(change*0.000001)) )) * 1000; //10
****
return priceNew;
****
|