Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C# I must code this program to give the calculations on the form I have listed b

ID: 3823018 • Letter: C

Question

C#

I must code this program to give the calculations on the form I have listed below in the screen shot. I have the form styled as I need it but I just need to get the code that does the calculations. Here is what I have to start with.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Chapter9Program1
{
    public partial class galUsedLbl : Form
    {
        public galUsedLbl()
        {
            InitializeComponent();
        }

        private void destinationTxt_TextChanged(object sender, EventArgs e)
        {

        }

        private void mileTravelTxt_TextChanged(object sender, EventArgs e)
        {

        }

        private void titleLbl_Click(object sender, EventArgs e)
        {

        }
    }
}

File Edit View Window Help Home Tools Project 202).pdf Chapter9PA1.pdf x /2 The user is to enter the destination, miles traveled and gallons consumed. When the "Calculate MPG" button is pressed it will display the Miles per gallon. When the "Reset" button is pressed the fields will clear: a Trip Calculator Miles Per Gallon Calculator Destin aton Tampa Mies Traveled 600 Gallons consumed 200 Calculate MPG Reset Miles per Galon: 3.0 Laura

Explanation / Answer

private void btnCalculate_Click(object sender, EventArgs e)

        {

             int miles, gallons

             double mpg;      

  

             miles = int.Parse(txtMiles.Text);

             gallons = int.Parse(txtGallons.Text);

mpg = (double)miles / (double)gallons;

             lblMPG.Text = mpg.ToString("N3");

        }