Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FARAH FRESNIDO HOA4
- TO DO LIST !:
- * work on design frame on that comp
- * do groupbox control
- * change messagebox to label 3 & put formula there !
- * click on button1 first before copy pasting codes
- * why doesnt it work when not both fields are filled up ? work on that.
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- private void Button1_Click(object sender, RoutedEventArgs e)
- {
- double weight = double.Parse(Textbox1.Text);
- double height = double.Parse(Textbox2.Text);
- if ((Textbox1.Text == "" || Textbox2.Text == "") || (Textbox1.Text == "" && Textbox2.Text == ""))
- {
- MessageBox.Show("Error: Don't leave anything blank.");
- }
- else if (Textbox1.Text != "" && Textbox2.Text != "")
- {
- double BMI = (weight * 0.45) / ((height * 0.025) * (height * 0.025));
- MessageBox.Show("BMI: " + BMI);
- Textbox1.Text = "";
- Textbox2.Text = "";
- }
- }
- private void Button1a_Click(object sender, RoutedEventArgs e)
- {
- double start = double.Parse(Textbox1a.Text);
- double end = double.Parse(Textbox2a.Text);
- if ((Textbox1a.Text == "" || Textbox2a.Text == "") || (Textbox1a.Text == "" && Textbox2a.Text == ""))
- {
- MessageBox.Show("Error: Don't leave anything blank.");
- }
- else if (Textbox1a.Text != "" && Textbox2a.Text != "")
- {
- if (end < start)
- {
- MessageBox.Show("Error: Starting value has to be less than the ending value.");
- }
- else if (end > start)
- {
- double n = end - start + 1;
- double sum = n * ((end + start) / 2);
- MessageBox.Show("Sum: " + sum);
- Textbox1a.Text = "";
- Textbox2a.Text = "";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement