I cannot seem to get my second switch to work, it looks identical to the first one that switch works fine, and everything after the second switch works fine. I cannot get the variable 'discount percentage' to update based of the case. (its just a Uni weekly task) Any ideas?
function ticketQ() {
var ticketType=prompt("What type of tickets do you want?")
var ticketQty=parseInt(prompt("How many tickets do you want?"))
document.write("The ticket type is " +ticketType +"<br>")
document.write("The ticket quantity is " +ticketQty +"<br>")
var ticketPrice=parseInt(0);
switch(ticketType) {
case (ticketType="A"):
var ticketPrice=parseInt(100)
break;
case (ticketType="B"):
var ticketPrice=parseInt(75)
break;
case (ticketType="C"):
var ticketPrice=parseInt(50)
break;
default:
document.write("Invalid ticket type" +"<br>");
break;
}
if (ticketQty >100 || ticketQty <1){
document.write("InvalidQty" +"<br>")
}if (ticketPrice >0 && ticketQty >0 && ticketQty <100){
var grossAmount=parseInt(ticketPrice * ticketQty)
}
var discountPercent=parseInt(0);
switch(grossAmount) {
case (grossAmount >200):
var discountPercent=parseInt(50);
break;
case (grossAmount >200):
var discountPercent=parseInt(5);
break;
// case (grossAmount ):
// var discountPercent=parseInt()
// break:
// case (grossAmount ):
// var discountPercent=parseInt()
// break;
default:
document.write("wrong" +"<br>")
break;
}
var discountAmount=parseInt((discountPercent / 100) *grossAmount)
var nettAmount=parseInt(grossAmount - discountAmount)
document.write("Gross Amount: $" + grossAmount + "<br>")
document.write("Discount Percent: " + discountPercent + "%" + "<br>")
document.write("Discount Amount: $" + discountAmount + "<br>")
document.write ("Nett Amount: $" + nettAmount + "<br>")
}