function BasicSTDCalculator() { const [speed, setSpeed] = useState(''); const [distance, setDistance] = useState(''); const [time, setTime] = useState(''); const [speedUnit, setSpeedUnit] = useState('kmh'); const [result, setResult] = useState(null); const calculate = () => { const s = parseFloat(speed); const d = parseFloat(distance); const t = parseFloat(time); let calculated = {}; if (s && d && !t) { // Calculate time calculated.time = (d / s).toFixed(2); calculated.formula = 'Time = Distance / Speed'; calculated.calculation = `${d} / ${s} = ${calculated.time} hours`; } else if (s && t && !d) { // Calculate distance calculated.distance = (s * t).toFixed(2); calculated.formula = 'Distance = Speed × Time'; calculated.calculation = `${s} × ${t} = ${calculated.distance} km`; } else if (d && t && !s) { // Calculate speed calculated.speed = (d / t).toFixed(2); calculated.formula = 'Speed = Distance / Time'; calculated.calculation = `${d} / ${t} = ${calculated.speed} km/h`; } setResult(calculated); }; return (