Advertisement
satyaki30

max min

Feb 9th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 KB | None | 0 0
  1. //6. Maximum and minimum of three numbers
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10.  
  11. namespace min_max
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void button1_Click(object sender, EventArgs e)
  21.         {
  22.             //find max button
  23.             int max;
  24.             max = int.Parse(textBox1.Text);
  25.  
  26.             if (max < int.Parse(textBox2.Text))
  27.                 max = int.Parse(textBox2.Text);
  28.            
  29.             if (max < int.Parse(textBox3.Text))
  30.                 max = int.Parse(textBox3.Text);
  31.  
  32.             textBox4.Text = max.ToString();
  33.         }
  34.  
  35.         private void button2_Click(object sender, EventArgs e)
  36.         {
  37.             //find min button
  38.             int min;
  39.             min = int.Parse(textBox1.Text);
  40.  
  41.             if (min > int.Parse(textBox2.Text))
  42.                 min = int.Parse(textBox2.Text);
  43.  
  44.             if (min > int.Parse(textBox3.Text))
  45.                 min = int.Parse(textBox3.Text);
  46.  
  47.             textBox5.Text = min.ToString();
  48.         }
  49.  
  50.         private void button3_Click(object sender, EventArgs e)
  51.         {
  52.             //reset function
  53.             textBox1.Clear();
  54.             textBox2.Clear();
  55.             textBox3.Clear();
  56.             textBox4.Clear();
  57.             textBox5.Clear();
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement