37 lines
1013 B
C#
37 lines
1013 B
C#
|
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();
|
||
|
}
|
||
|
}
|
||
|
}
|