C
Class Kullanarak Dik Üçgende Alan ve Çevre Hesaplama
Ucgen.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Class_Ucgen { class Ucgen { double kenar1; double kenar2; public double Kenar1 { get { return kenar1; } set { kenar1 = value; } } public double Kenar2 { get { return kenar2; } set { kenar2 = value; } } public double AlanHesapla() { return (kenar1 * kenar2) / 2; } public double CevreHesapla() { double hipotenus = Math.Sqrt(Math.Pow(kenar1, 2) + (Math.Pow(kenar2, 2))); return (kenar1 + kenar2 + hipotenus); } } }
Button1_Click
private void button1_Click(object sender, EventArgs e) { Ucgen dikucgen = new Ucgen(); dikucgen.Kenar1 = Convert.ToDouble(textBox1.Text); dikucgen.Kenar2 = Convert.ToDouble(textBox2.Text); label2.Text = dikucgen.AlanHesapla().ToString(); label5.Text = dikucgen.CevreHesapla().ToString(); }