levi15791

Oct 11th, 2010, 12:57 PM

<html>

<script>

// Author: L Freeman

// Date: 11/10/10

// Purpose: Calculate student discount/vat reductions

var price = 0;

var vat = 17.5;

var discount = 10;

var reduction = 0;

var deduction = 0;

var reductionVAT = 0;

var priceDiscount = 0;

var priceNoVATDiscount = 0;

// Calculate new price

price = prompt("Enter price:");

// Calculate reduction

reduction = (price/100) * discount;

priceDiscount = (reductionVAT-reduction);

priceNoVATDiscount = (price - reduction);

// Calculate vat deduction

deduction = (price/100) * vat;

reductionVAT = (price - deduction);

// Is VAT and/or a discount required?

var answer = confirm ("VAT required?")

if (answer)

{

alert ("Price = " + price + ", VAT = " + deduction + ", New Price is: " + reductionVAT)

var answer = confirm ("Discount Required?")

if (answer)

{

alert ("Price = " + reductionVAT + ", Discount = " + reduction + "New price is: " + priceDiscount)

else

alert ("No Discount Required. Price is: " + reductionVAT)

}

else

alert ("No VAT required.")

var answer = confirm ("Discount Required?")

{

if (answer)

alert ("Price = " + price + ", Discount = " + reduction + "New price is: " + priceNoVATDiscount)

else

alert ("No Discount Required. Price is: " + price)

}

}

</script>

</html>

I am having trouble getting this to work properly. What I am trying to do is come up with a simple vat deduction + student discount calculator. I cannot seem to get it working.

<script>

// Author: L Freeman

// Date: 11/10/10

// Purpose: Calculate student discount/vat reductions

var price = 0;

var vat = 17.5;

var discount = 10;

var reduction = 0;

var deduction = 0;

var reductionVAT = 0;

var priceDiscount = 0;

var priceNoVATDiscount = 0;

// Calculate new price

price = prompt("Enter price:");

// Calculate reduction

reduction = (price/100) * discount;

priceDiscount = (reductionVAT-reduction);

priceNoVATDiscount = (price - reduction);

// Calculate vat deduction

deduction = (price/100) * vat;

reductionVAT = (price - deduction);

// Is VAT and/or a discount required?

var answer = confirm ("VAT required?")

if (answer)

{

alert ("Price = " + price + ", VAT = " + deduction + ", New Price is: " + reductionVAT)

var answer = confirm ("Discount Required?")

if (answer)

{

alert ("Price = " + reductionVAT + ", Discount = " + reduction + "New price is: " + priceDiscount)

else

alert ("No Discount Required. Price is: " + reductionVAT)

}

else

alert ("No VAT required.")

var answer = confirm ("Discount Required?")

{

if (answer)

alert ("Price = " + price + ", Discount = " + reduction + "New price is: " + priceNoVATDiscount)

else

alert ("No Discount Required. Price is: " + price)

}

}

</script>

</html>

I am having trouble getting this to work properly. What I am trying to do is come up with a simple vat deduction + student discount calculator. I cannot seem to get it working.