ASDV-C-Sharp/lab5_2/lab5_3_CalebFontenot/Form1.cs

37 lines
1013 B
C#
Raw Normal View History

2022-10-13 13:03:15 -05:00
namespace lab5_3_CalebFontenot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void displayButton_Click(object sender, EventArgs e)
{
// Define variables
const int START_SPEED = 60;
const int END_SPEED = 130;
const int INTERVAL = 10;
const double CONVERSION_FACTOR = 0.6214;
int kph;
double mph;
// Display the table of speeds.
for (kph = START_SPEED; kph <= END_SPEED; kph += INTERVAL)
{
// Calculate miles per hour.
mph = kph * CONVERSION_FACTOR;
// Display the conversion
outputListBox.Items.Add(kph + " KPH is the same as " + mph + " MPH");
}
}
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
}
}