Ad

Restaurant have to calcute the final price which include Value Added Tax(VAT) and service charge.

Service charge only calculated for dine in.

We need your help to make a function to calculate the final price.

Note:
-VAT rate is 10%
-service charge rate is 5%
-service charge is taxable
-the final price should be round down.

Example:
-if the price is 100 and take away, the final price would be 110
-if the price is 100 and dine in, the final price would be 105

function finalPrice(price,dineIn) {
  var service = 0.05
  var VAT = 0.1
  
  if(dineIn == true) {
    return Math.floor(price * (1 +service) * (1+ VAT)) }
  else {
    return Math.floor(price * (1+ VAT))
  }
   
  
}

A customer pays a goods for 100 (price) and they must pay additonal tax 10 (VAT rate 10%). The final price will be 110.

If the customer pays goods with price greater than or equal 1000, the customers will pay additional luxury tax with rate 30%.

We need your help to make a formula to calculate the final price (include tax).

Information:
VAT rate = 10%
Luxury tax rate* = 30%
*imposed only if the goods and services price greater than or equal 1000

function finalPrice(price) {
  var vat = 0.1
  var lux = 0.3
  
  if(price >= 1000) {
  return Math.floor(price * (1+vat+lux))
    } else {
      return Math.floor(price * (1+vat))
    }
}