This commit is contained in:
2022-11-15 14:22:17 -06:00
parent c2062a2a38
commit ab09a46923
268 changed files with 1961 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
namespace lab6_4_CalebFontenot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/*
* The CupsToOunces method accepts a number of cups as an argument and returns the equivalent number of fluid ounces.
*/
private double CupsToOunces(double cups)
{
return cups * 8.0;
}
private void convertButton_Click(object sender, EventArgs e)
{
double cups, ounces = 0;
// Get the number of cups.
if (double.TryParse(cupsTextBox.Text, out cups))
{
// Convert the cups to ounces.
ounces = CupsToOunces(cups);
// Display the ounces
ouncesTextBox.Text = ounces.ToString("n1");
}
else
{
// Display an error message.
MessageBox.Show("Enter a valid number.");
}
}
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
}
}