45 - Matematik Sınıfı

 






using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MatematikSinifi
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        MatematikMetotlari mat=new MatematikMetotlari();

        private void button1_Click(object sender, EventArgs e)
        {

                int sayi = int.Parse(textBox1.Text);
                int kare = mat.kareal(sayi);
                label1.Text = kare.ToString();
 
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int sayi = int.Parse(textBox1.Text);
            int kup = mat.kupAl(sayi);
            label1.Text = kup.ToString();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            int sayi = int.Parse(textBox1.Text);
            label1.Text = mat.mutlak(sayi).ToString();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            int sayi = Convert.ToInt16(textBox1.Text);
            label1.Text = mat.faktoriyel(sayi).ToString();
        }
     
    }

    public class MatematikMetotlari
    {
        public int kareal(int a)
        {
            int sonuc = a * a;
            return sonuc;
        }

        public int kupAl(int a)
        {
            int sonuc = a * a * a;
            return sonuc;
        }

        public int mutlak(int a)
        {
            if (a<0)
            {
                a = a * -1;
            }
            return a;
        }
       
        public int faktoriyel(int a)
        {
            int faktoriyelSonuc = 1;
            for (int i =a; i >= 1; i--)
            {
                faktoriyelSonuc = faktoriyelSonuc * i;
            }
            return faktoriyelSonuc;
        }
    }
}


Yorumlar

Bu blogdaki popüler yayınlar

14 - Dizi Oluşturma, Değer Atama

12 - Bir Boyutlu Diziler - Çalışma Soruları

27 - Koleksiyonlar: ArrayList()