https://lh4.googleusercontent.com/-Td_5JW1p5Hk/T5Uxz0kbNLI/AAAAAAAAALg/GGY6QenBugs/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");
            }
        }
     }
}