daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest May 19th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head> Javascript Tip Calculator </head>
  3.  
  4. <body>
  5.  
  6. <script type="text/javascript">
  7. <!--
  8.  
  9. document.write("");
  10.  
  11.  
  12. var Total = 0;
  13. var NineTip = 1.09;
  14. var SevenTip = 1.07;
  15. var MealPrice = 0;
  16.  
  17. while (MealPrice != -1) {
  18.  
  19.     MealPrice = parseFloat(prompt("Please Enter Meal Price"));
  20.    
  21.     while (MealPrice < -1){
  22.         alert("Meal Price wasnt more than 0");
  23.         MealPrice = prompt("Enter Meal Price");
  24.     }
  25.  
  26.     if (MealPrice <= 100){
  27.         Total = Total + (MealPrice * NineTip);
  28.     }
  29.     else{
  30.         Total = Total + (MealPrice * SevenTip);
  31.     }  
  32.  
  33. }
  34.  
  35. Total = Total + 1.09
  36.  
  37. document.write("<h2>");
  38.  
  39.  
  40. document.write("Total is "+ Total);
  41.  
  42.  
  43. //-->
  44. </script>
  45.  
  46. </script>
  47. </body>
  48. </html>
RAW Paste Data
Top