Newbie having trouble with 'while loop'
Really getting frustrated with this homework assignment.
Screwed up my entire weekend and it is due tomorrow.
I have this script starting over so that another food bill could be tried again.
The problem has been that to opt out of the script and discontinue the viewer must type -999
var bill = purchasePrice(); //price on the food bill
caculateTotalBill(bill); //Tip plus food bill
pp = parseFloat(prompt("Input how much your meal purchase is. To exit type -999", ""));
var MINPRICE = .10;
var MAXPRICE = 1000;
//Validate the inputted pp
if (pp = -999)
while((isNaN(pp)) || (pp < MINPRICE) || (pp > MAXPRICE))
alert("Invalid purchase price inputted. Please reenter.");
pp = parseFloat(prompt("Input how much your meal purchase is", ""));
var TIP = 0.15; //Going rate for tip
var TAX = 0.07; //tax
var theTip = bill * TIP;
var theTax = bill * TAX;
var totalBill = bill + theTip + theTax;
outputInfo(bill, theTip, theTax, totalBill);
function outputInfo (bill, theTip, theTax, totalBill)
alert("Meal purchase price: " + "\t\t" + bill.toFixed(2) + "\n" +
"Tip: " + "\t\t\t\t\t\t" + theTip.toFixed(2) + "\n" +
"Tax: " + "\t\t\t\t\t" + theTax.toFixed(2) + "\n" +
"Your total bill will be: " + "\t\t" + totalBill.toFixed(2));
while (bill != -999)
alert("Thanks! See ya!");
What if they want to run again?
That will help me exit the program but what if they want to run it again?
Originally Posted by 007Julien