Files
ASDV-WebDev/Semester 1/Assignments/JavaScript/ch05/ch05/ex_5_15.html
2023-08-16 17:31:33 -05:00

39 lines
1.1 KiB
HTML
Executable File

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Example 5.15</title>
<script>
function getReceipts()
{
var week = 0; var day = 0; var subtotal = 0; var count = 0;
receipt = 0;
total = 0;
for (week = 1; week < 3; week++)
{
document.write("<h3>Week " + week + "</h3>");
count = 1; subtotal = 0;
for (day = 1; day < 8; day++)
{
receipt = parseFloat(prompt("Enter the receipts for day " + day + ": " , ""));
document.write("amount for day " + count + ": $ " + receipt.toFixed(2) + "<br />");
subtotal = subtotal + receipt;
count++;
}
document.write("<p>Week " + week + " subtotal is $ " + subtotal.toFixed(2) + "</p>");
total = total + subtotal;
}
document.write("<p>The total amount for these weeks is $ " + total.toFixed(2) + "</p>");
}
</script>
</<head>
<body>
<table align ="center" width ="70%"><tr><td colspan ="2">
<h1>&nbsp;</h2>
<h1>Subtotals</h1>
<h3>Click to enter receipts</h3>
<p><input type="button" id="nesting" value="Enter receipts" onclick="getReceipts();" /></p>
</td></tr>
</table></body>
</html>