Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- public partial class FuelConsumptionFrm : Form
- {
- public FuelConsumptionFrm()
- {
- InitializeComponent();
- }
- private void CalculateConsumptionBtn_Click(object sender, EventArgs e)
- {
- double dblLitres = (Convert.ToDouble(FuelTotalCostTxtBox.Text) / (Convert.ToDouble(FuelPriceTxtBox.Text) / 100));
- double dblDistance = Convert.ToDouble(CurrentOdometerTxtBox.Text) - Convert.ToDouble(PreviousOdometerTxtBox.Text);
- double dblLitresPerHundredKm = (dblLitres / dblDistance) * 100;
- ShowConsumptionLitresLbl.Text = "Consumption is " + Convert.ToString(dblLitresPerHundredKm) + " L/100km";
- double dblMilesPerGallon = FuelConsumptionMilesPerGallon(dblLitresPerHundredKm);
- ShowConsumptionMilesLbl.Text = "or " + Convert.ToString(dblMilesPerGallon) + " mpg.";
- Graphics graConsumption = KmPLGraphPicBox.CreateGraphics();
- graConsumption.Clear(Color.Gold);
- SolidBrush brsBlack = new SolidBrush(Color.Black);
- graConsumption.FillRectangle(brsBlack, (Convert.ToInt32(dblLitresPerHundredKm) * 10), 0, 5, 30);
- }
- private double FuelConsumptionMilesPerGallon(double dblLitresPerHundredKm);
- double dblMilesPerGallon = 0;
- double dblMilesPerGallon = 454.6 / (1.609 * dblLitresPerHundredKm);
- }
- }
Add Comment
Please, Sign In to add comment