Fuel Cost Calculator In Malaysia

Trip Distance
Fuel Efficiency
Gas/Fuel Price

Also Visit : Car Insurance Calculator

Sample Fuel Cost Calculator:

import React, { useState } from 'react';

export default function FuelCostCalculator() {
  const [distance, setDistance] = useState('');
  const [fuelEfficiency, setFuelEfficiency] = useState('');
  const [fuelPrice, setFuelPrice] = useState('');
  const [fuelCost, setFuelCost] = useState(null);

  const calculateFuelCost = () => {
    if (distance && fuelEfficiency && fuelPrice) {
      const cost = (distance / fuelEfficiency) * fuelPrice;
      setFuelCost(cost.toFixed(2));
    }
  };

  return (
    <div className="calculator">
      <h2>Fuel Cost Calculator</h2>
      <label>
        Distance (km):
        <input type="number" value={distance} onChange={(e) => setDistance(e.target.value)} />
      </label>
      <label>
        Fuel Efficiency (km/l):
        <input type="number" value={fuelEfficiency} onChange={(e) => setFuelEfficiency(e.target.value)} />
      </label>
      <label>
        Fuel Price per Liter (RM):
        <input type="number" value={fuelPrice} onChange={(e) => setFuelPrice(e.target.value)} />
      </label>
      <button onClick={calculateFuelCost}>Calculate</button>
      {fuelCost !== null && <p>Estimated Fuel Cost: RM {fuelCost}</p>}
    </div>
  );
}

Rocky Islam

Hi, I'm Rocky Islam, founder of Carlistmalaysia. This website provides authentic information regarding new car prices, specifications, comparisons, reviews, and features.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button