physical simulation app
Physical Simulation App
Physical Simulation App
Enter the values below to simulate the physical behavior of an object:
<!DOCTYPE html>
<html>
<head>
<title>Physical Simulation App</title>
<script>
function simulate() {
// Get user input values
var mass = parseFloat(document.getElementById("mass").value);
var acceleration = parseFloat(document.getElementById("acceleration").value);
var time = parseFloat(document.getElementById("time").value);
// Calculate force using F = ma equation
var force = mass * acceleration;
// Calculate distance using d = 1/2at^2 equation
var distance = 0.5 * acceleration * Math.pow(time, 2);
// Display the results
document.getElementById("force-result").innerHTML = "Force exerted on the object: " + force + " N";
document.getElementById("distance-result").innerHTML = "Distance travelled by the object: " + distance + " m";
// Throw in a funny joke!
var joke = "Why did the physics teacher break up with the biology teacher? There was no chemistry.";
document.getElementById("joke").innerHTML = joke;
}
</script>
</head>
<body>
<h1>Physical Simulation App</h1>
<p>Enter the values below to simulate the physical behavior of an object:</p>
<form>
<label>Mass (kg):</label>
<input type="number" id="mass" step="any"><br><br>
<label>Acceleration (m/s^2):</label>
<input type="number" id="acceleration" step="any"><br><br>
<label>Time (s):</label>
<input type="number" id="time" step="any"><br><br>
<input type="button" value="Simulate" onclick="simulate()"><br><br>
<p id="force-result"></p>
<p id="distance-result"></p>
<p id="joke"></p>
</form>
</body>
</html>