Asked By
jaycepierce
10 points
N/A
Posted on - 10/27/2012
Hello experts,
What is the best java script for calculating prices? I am creating a store system using java programming language and needs to get the proper algorithm on calculating prices that has been added to the customer’s cart. Can you give me a some code illustration and I will just edit it as a reference?
What is the best java script for calculating prices?
Â
Calculation algorithm may vary according to your needs. Consider a below kind of a algorithm
Double[] Itemprice={Price};
Double Tax;
Double OtherCharges;
Double Discount;
Double FinalCustomerPrice=0;
for(int i = 0; i < Itemprice.length; i++)
 {
     FinalCustomerPrice= FinalCustomerPrice +(( Itemprice[i] + Tax+ OtherCharges) – Discount)Â
 }
Â
return FinalCustomerPrice
Store the prices of several items in a array which the customer has selected. Do the other reductions and additions to the original price and finally loop through the array to calculate the final value. You may modify the algorithm according to your needs.