Guest User

Untitled

a guest
Jul 16th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. {
  2.     public partial class FuelConsumptionFrm : Form
  3.     {
  4.         public FuelConsumptionFrm()
  5.         {
  6.             InitializeComponent();
  7.         }
  8.  
  9.         private void CalculateConsumptionBtn_Click(object sender, EventArgs e)
  10.         {
  11.             double dblLitres = (Convert.ToDouble(FuelTotalCostTxtBox.Text) / (Convert.ToDouble(FuelPriceTxtBox.Text) / 100));
  12.             double dblDistance = Convert.ToDouble(CurrentOdometerTxtBox.Text) - Convert.ToDouble(PreviousOdometerTxtBox.Text);
  13.             double dblLitresPerHundredKm = (dblLitres / dblDistance) * 100;
  14.  
  15.             ShowConsumptionLitresLbl.Text = "Consumption is " + Convert.ToString(dblLitresPerHundredKm) + " L/100km";
  16.  
  17.             double dblMilesPerGallon = FuelConsumptionMilesPerGallon(dblLitresPerHundredKm);
  18.  
  19.             ShowConsumptionMilesLbl.Text = "or " + Convert.ToString(dblMilesPerGallon) + " mpg.";
  20.  
  21.             Graphics graConsumption = KmPLGraphPicBox.CreateGraphics();
  22.             graConsumption.Clear(Color.Gold);
  23.             SolidBrush brsBlack = new SolidBrush(Color.Black);
  24.             graConsumption.FillRectangle(brsBlack, (Convert.ToInt32(dblLitresPerHundredKm) * 10), 0, 5, 30);
  25.         }
  26.  
  27.         private double FuelConsumptionMilesPerGallon(double dblLitresPerHundredKm);
  28.         double dblMilesPerGallon = 0;
  29.         double dblMilesPerGallon = 454.6 / (1.609 * dblLitresPerHundredKm);
  30.        
  31.     }
  32. }
Add Comment
Please, Sign In to add comment