3 Nisan 2013 Çarşamba

1 - İf Kullanımı... Geçti Kaldı...


Formu aşağıdaki gibi tasarlayınız... 

Program çalıştırıldığında aşağıdaki gibi bir görüntü gelecektir... 



Programın Kodları;

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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int y1, y2, y3, ort; // Değişkenler tanımlanıyor... 
            y1 = Convert.ToInt32(textBox1.Text); // 3 sayının girişi yapılıyor... 
            y2 = Convert.ToInt32(textBox2.Text);
            y3 = Convert.ToInt32(textBox3.Text);

            ort = (y1 + y2 + y3) / 3; // Ortalama hesaplatılıyor... 
            MessageBox.Show("Ortalama = " + ort); //MessageBox ile ekrana mesaj verdiriyoruz... 

            if (ort > 44) // İf ile birlikte ortalama değerine göre geçti veya kaldı yazdırıyoruz... 
                label4.Text = "Geçti";
            else
                label4.Text = "Kaldı";
        }
    }
}