Skip to content

Instantly share code, notes, and snippets.

Created February 11, 2016 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/86e0964f92801a011454 to your computer and use it in GitHub Desktop.
Save anonymous/86e0964f92801a011454 to your computer and use it in GitHub Desktop.
tipCalculator
var CheckAmount = prompt("Enter Check Amount");
var taxAmount = (CheckAmount * 0.07).toFixed(2);
var tipLevel1 = (CheckAmount * 0.10).toFixed(2);
var tipLevel2 = (CheckAmount * 0.15).toFixed(2);
var tipLevel3 = (CheckAmount * 0.20).toFixed(2);
var totalBill = (Number(CheckAmount) + Number(taxAmount) + Number(tipLevel2)).toFixed(2);
console.log("Base Amount: " + CheckAmount + "\n Tax (7%): "+Number(taxAmount)+"\nTip for stingy customers (10%): "+ tipLevel1 + "\nTip for regular customers (15%): "+tipLevel2+"\nTip for generous customers (20%): "+tipLevel3+ "\nTotal with tax and tip for regular customers: "+Number(totalBill));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment