private void btDivide_Click(object sender, EventArgs e) { int whole1 = Convert.ToInt32(txtWhole1.Text), whole2 = Convert.ToInt32(txtWhole2.Text), nume1 = Convert.ToInt32(txtNumerator1.Text), nume2 = Convert.ToInt32(txtNumerator2.Text), denom1 = Convert.ToInt32(txtDenominator1.Text), denom2 = Convert.ToInt32(txtDenominator2.Text); m1 = new MixedFraction(whole1, nume1, denom1); m2 = new MixedFraction(whole2, nume2, denom2); f3 = m1 / m2; m3 = new MixedFraction(); m3.ToMixedFraction(f3); UpdateDisplay(); }
private void btMutiply_Click(object sender, EventArgs e) { int whole1, whole2, nume1, nume2, denom1, denom2; if (Int32.TryParse(txtNumerator1.Text, out nume1) && Int32.TryParse(txtNumerator2.Text, out nume2) && Int32.TryParse(txtDenominator1.Text, out denom1) && Int32.TryParse(txtDenominator2.Text, out denom2) && Int32.TryParse(txtWhole1.Text, out whole1) && Int32.TryParse(txtWhole2.Text, out whole2) ) { try { m1 = new MixedFraction(whole1, nume1, denom1); m2 = new MixedFraction(whole2, nume2, denom2); f3 = m1 * m2; m3 = new MixedFraction(); m3.ToMixedFraction(f3); UpdateDisplay(); } catch (DivideByZeroException d0) { MessageBox.Show(d0.Message); } } else { MessageBox.Show("Illegal Character entered or t too many characters"); } }