ASDV-WebDev/Semester 1/Assignments/JavaScript/MP10_CalebFontenot/public_html/Problem 5.html
2023-08-16 17:31:33 -05:00

37 lines
1.3 KiB
HTML

<!DOCTYPE html>
<!--
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/html.html to edit this template
-->
<html>
<head>
<title>Bacteria cultivation calculator</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
table, th, td {
border: 1px solid;
text-align: center;
}
</style>
<script>
var initialBacteria = prompt("Enter the initial bacteria.");
var bacteria = initialBacteria;
document.write("<table>");
// Write table header
document.write("<tr><th>Initial Bacteria Present:</th><th>"+initialBacteria +"</th></tr>");
document.write("<tr><th>Bacteria</th><th>Day</th></tr>");
for (var i = 1; i <= 10; i++) {
document.write("<tr>");
bacteria = initialBacteria * Math.pow(2, (i / 10)) ;
bacteria = Math.trunc(bacteria);
document.write("<td>" + bacteria + "</td>");
document.write("<td>" + i + "</td>");
document.write("</tr>");
}
document.write("</table>");
</script>
</head>
</html>