Create a page that will allow users to enter the total amount for a bill, the number of people splitting the bill, and the tip percentage that should be used. All of these values can be entered using text fields, but you may use a drop-down menu or radio buttons to allow the user to select the tip amount that they want to use. When the user clicks a button to calculate the amount it should call a function in an associated JavaScript file that will perform the calcuation. This function should have four parameters, the first which is the amount of the bill, the second of which is the tax rate, the third of which is the number of people splitting the bill, and the last of which is the desired tip rate. The function should calculate the total amount due including tax and split it evenly amongst everyone. The tip should be calculated without tax. The function should create and return a String that looks similar to the following: "The bill of $100.00 with 8% tax comes to a total of $108.00. With 4 people splitting the bill, each person should pay $27.00 for the meal. Each person should also leave $5.00 towards the 20% tip, for a total of $33.00 per person."
Create a page that will allow users to enter the total amount for a bill, the number of people splitting the bill, and the tip percentage that should be used. All of these values can be entered using text fields, but you may use a drop-down menu or radio buttons to allow the user to select the tip amount that they want to use. When the user clicks a button to calculate the amount it should call a function in an associated JavaScript file that will perform the calcuation. This function should have four parameters, the first which is the amount of the bill, the second of which is the tax rate, the third of which is the number of people splitting the bill, and the last of which is the desired tip rate. The function should calculate the total amount due including tax and split it evenly amongst everyone. The tip should be calculated without tax. The function should create and return a String that looks similar to the following:
"The bill of $100.00 with 8% tax comes to a total of $108.00. With 4 people splitting the bill, each person should pay $27.00 for the meal. Each person should also leave $5.00 towards the 20% tip, for a total of $33.00 per person."
Your page can use the alert function to display this message as a pop-up. Alternatively you can write it directly to page or otherwise put the information into various form components if you'd like.
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 2 images