The cost of making a pepperoni pizza at “Pizza Joe’s” is $12.95. A Hawaiian is $14.95. Tax is 5%.
The owners asks you to write a program where they enter the number of pepperoni and
Hawaiian pizzas and the subtotal, tax, and total is displayed neatly on the screen. Use tables to
display the result neatly. just java script plz
<html>
<head>
<title>Pizza</title>
<script language="javascript" type="text/javascript">
window.onload = function () {
btnCalculate.addEventListener("click", displayResult);
function displayResult() {
if (txtPizzaJoe.value == "") {
alert("Enter the number of Pizza Joe!!!")
return;
}
if (txtPizzaHawaiian.value == "") {
alert("Enter the number of Pizza Hawaiian!!!")
return;
}
let numberPizzaJoe=parseInt(txtPizzaJoe.value)
let numberPizzaHawaiian=parseInt(txtPizzaHawaiian.value)
let subtotal=numberPizzaJoe*12.95+numberPizzaHawaiian*14.95;
let tax=subtotal*0.05;
let total=tax+subtotal;
txtSubtotal.value="$"+subtotal.toFixed(2);
txtTax.value="$"+tax.toFixed(2);
txtTotal.value="$"+total.toFixed(2);
};
}
</script>
</head>
<body>
<form>
<table>
<tr>
<td></td>
<td> Quantity</td>
</tr>
<tr>
<tr>
<td>Pizza Joe's ($12.95):</td>
<td> <input id="txtPizzaJoe" type="text" value=""></td>
</tr>
<tr>
<td>Hawaiian ($14.95):</td>
<td> <input id="txtPizzaHawaiian" type="text" value=""></td>
</tr>
<tr>
<td>Subtotal:</td>
<td> <input id="txtSubtotal" type="text" value="" readonly></td>
</tr>
<tr>
<td>Tax (5%):</td>
<td> <input id="txtTax" type="text" value="" readonly></td>
</tr>
<tr>
<td>Total:</td>
<td> <input id="txtTotal" type="text" value="" readonly></td>
</tr>
<tr>
<td></td>
<td> </td>
</tr>
<tr>
<td></td>
<td><input id="btnCalculate" type="button" value="Calculate"></td>
</tr>
</table>
</form>
</html>
Comments
Leave a comment