https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgapRk17SnMsVIP4rqKxYUNj-T4nFh5fp1xlBeTBJBzieGrQPlMWrPi4OVEEHXvHy9pEfVdR_PYY149yBCYT0rpSqrvNq5yAc2p-gIhYtkPo0JLohWiy1nayyD1FiKKyHEAyUqFJZxfR50/s256/Letter-R-icon.png

Thursday, May 31, 2012

Contoh Program C# if else if menentukan predikat suatu nilai

 Contoh Program C# if else if menentukan predikat suatu nilai


using System;
using System.Windows.Forms;

namespace Ifstatment
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void buttonCek_Click(object sender, EventArgs e)
        {
            int nilai;

            nilai = Convert.ToInt16(textBoxNilai.Text);

            if ((nilai >= 80) && (nilai <= 100))
            {
                MessageBox.Show("Nilai A");
            }
            else if ((nilai >= 70) && (nilai <= 80))
            {
                MessageBox.Show("Nilai B");
            }
            else if ((nilai >= 60) && (nilai <= 70))
            {
                MessageBox.Show("Nilai C");
            }
            else if ((nilai >= 45) && (nilai <= 60))
            {
                MessageBox.Show("Nilai D");
            }
            else
            {
                MessageBox.Show("Nilai E");
            }
        }
     }
}