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)
{
}
}
}
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");
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.