Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program called restaurant.js, that calculates the tab for a couple based

ID: 3682789 • Letter: W

Question

Write a program called restaurant.js, that calculates the tab for a couple based on the use of a gift certificate and the items ordered. Since we are not collecting input from the users, use the same literal values for the appetizer, entrée, drinks and dessert that you see in my example below. The total for ordered items, restaurant tax, and tab should be calculation and not hardcoded print statements.

An example execution of the program is given below:

This program will calculate a restaurant tab for a couple with a gift certificate, with a restaurant tax of 8.0%

Amount of gift certificate: 200

Ordered Items for person 1

Appetizer: 5.50

Entrée: 21.50

Drinks: 4.25

Dessert: 6.00

Ordered Items for person 2

Appetizer: 6.25

Entrée: 18.50

Drinks: 6.50

Dessert: 5.50

Ordered Items: $74.00

Restaurant tax: $5.92

Tab: $ -120.08

(negative amount indicates unused amount of gift certificate)

25 pts

Explanation / Answer

<html>
   <head>
       <script language="Javascript">
           var ap1=5.50, ent1=21.5, d1=4.25, de1=5.5, ap2=6.25, ent2=18.5, d2=6.5, de2=5.5, orderi=0, restax=0, tab=0;

       </script>

   <body>
       <script language="Javascript">
           document.write("Amount of gift certificate: 200"+"<br>");
           document.write("Ordered Items for person 1"+"<br>");
           document.write("Appetizer:"+ap1+"<br>");
           document.write("Entree:"+ent1+"<br>");
           document.write("Drinks:"+d1+"<br>");
           document.write("Dessert:"+de1+"<br>"+"<br>");

           document.write("Ordered Items for person 2"+"<br>");
           document.write("Appetizer:"+ap2+"<br>");
           document.write("Entree:"+ent2+"<br>");
           document.write("Drinks:"+d2+"<br>");
           document.write("Dessert:"+de2+"<br>");

           orderi=ap1+ent1+d1+de1+ap2+ent2+d2+de2;

           restax=orderi*8/100;

           tab=(orderi+restax)-200;

           document.write("Ordered Items:"+orderi+"<br>");
           document.writ("Restaurant Tax:"+restax+"<br>");
           document.write("Tab:"+tab+"<br>");
       </script>
   </body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote