title: error message instead of NaN output and negative 'Nett Payment' output
body: <pre><code>var vDiscountPercent;
  var vGrossPayment;
  var vTicketType;
  vTicketType = prompt(" What type of Tickets is required?");
  document.write("The Ticket Type is: " + vTicketType);
  
  var vTicketQty;
  vTicketQty = prompt("How many Tickets are required?");
  document.write("&lt;br/&gt;");
  document.write("The Ticket Qty is: " + vTicketQty + "&lt;br/&gt;");
  var vTicketQty = parseInt(vTicketQty);
  
  if (isNaN(parseInt(vTicketQty))) {
      vTicketQty = 0;
  }
  
  if (vTicketQty &lt;= 0) {
      document.write("Invalid Qty" + "&lt;br/&gt;");
  } else {
      vTicketPrice = calcPrice(vTicketType);
      if (vTicketPrice == -1) {
          document.write("Invalid Ticket Type" + "&lt;br/&gt;");
      } else {
          document.write("Ticket Price is: " + vTicketPrice + "&lt;br/&gt;");
      }
      var vTotalPayment = calcTotal(vTicketPrice, vTicketQty);
      if (vTotalPayment &gt; 0) {
          document.write("Total payment required is: $" + vTotalPayment + "&lt;br/&gt;");
      } else {
          document.write("Invalid data supplied" + "&lt;br/&gt;");
      }
  }
  
  function calcTotal(vTicketPrice, vTicketQty) {
      return vTicketPrice * vTicketQty;
  }
  
  function calcPrice(vTicketType) {
      var vTicketPrice;
      if (vTicketType.toLowerCase() == "a") {
          vTicketPrice = 100;
      } else if (vTicketType.toLowerCase() == "b") {
          vTicketPrice = 75;
      } else if (vTicketType.toLowerCase() == "c") {
          vTicketPrice = 50;
      } else {
          vTicketPrice = -1;
      }
      return vTicketPrice;
  }
  
  vGrossPayment = vTotalPayment;
  var vGrossPayment = calcDiscountPercent(vGrossPayment);
  function calcDiscountPercent(vGrossPayment) {
  if (vGrossPayment &lt; 200) {
      document.write("Discount Percent: 0%");
      vDiscountPercent = 0;
  }   else if (vGrossPayment &lt; 400) {
      document.write("Discount Percent: 5%");
      vDiscountPercent = 0.05;
  }   else if (vGrossPayment &lt; 600) {
      document.write("Discount Percent: 7.5%");
      vDiscountPercent = 0.075;
  }   else if (vGrossPayment &gt; 600) {
      document.write("Discount Percent: 10%");
      vDiscountPercent = 0.10;
  }   else {
      document.write("No discount");
  } 
      return vDiscountPercent;
  }
  
  var applyDiscount = applyDiscount(vTotalPayment, vDiscountPercent);
  function applyDiscount(vTotalPayment, vDiscountPercent) {
      return vTotalPayment * (vDiscountPercent * 100) / 100;
  }
  document.write("&lt;br/&gt;" + "Discount Amount: $" + applyDiscount);
  
  var vNettPayment = calcDiscountAmount(vTotalPayment, applyDiscount);
  function calcDiscountAmount(vGrossPayment, vDiscountPercent) {
      return vTotalPayment - applyDiscount;
  }
  document.write("&lt;br/&gt;" + "Nett Payment: $" + vNettPayment);
  </code></pre>
  
  <p>At the moment when I enter a value that isn't between 1 to 100 in 'vTicketQty' the output is 'NaN' for 'Nett Payment' and 'Discount Amount', how do I get the output value to show an error message instead of NaN?
  Also when I don't enter 'a' , 'b' or 'c' for 'vTicketType' the output for 'Nett Payment" is negative, again how do I get the output to show an error message instead?</p>