html Copy code
Speed Converter Tool
Converted Speeds
- mph: 0
- kph: 0
- mps: 0
h1 { color: #343a40; } .card { background-color: #ffffff; border: 1px solid #ced4da; border-radius: 0.25rem; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); } .card-body { padding: 2rem; } .btn { background-color: #007bff; color: #ffffff; } .btn:hover { background-color: #0056b3; } .list-group-item { background-color: #ffffff; border: 1px solid #ced4da; } .list-group-item strong { color: #343a40; } JavaScript (script.js) javascript Copy code function convertSpeed() { const speed = parseFloat(document.getElementById('speedInput').value); const unit = document.getElementById('unitSelect').value; let mph, kph, mps; switch (unit) { case 'mph': mph = speed; kph = speed * 1.60934; mps = speed * 0.44704; break; case 'kph': mph = speed * 0.621371; kph = speed; mps = speed * 0.277778; break; case 'mps': mph = speed * 2.23694; kph = speed * 3.6; mps = speed; break; default: mph = 0; kph = 0; mps = 0; } document.getElementById('mphOutput').textContent = mph.toFixed(2); document.getElementById('kphOutput').textContent = kph.toFixed(2); document.getElementById('mpsOutput').textContent = mps.toFixed(2); }