visual studio c++ PEMBAGIAN BILANGAN GENAP DAN GANJIL.c++ |
from1 |
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BilanganGenap0rGanjil
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show("Anda belum Menginputkan Bilangan awal");
}
if (textBox2.Text == "")
{
MessageBox.Show("Anda belum Menginputkan Bilangan akhir");
}
int i;
int awal, akhir;
awal = int.Parse(textBox1.Text);
akhir = int.Parse(textBox2.Text);
for (i = awal; i <= akhir; i++)
{
if (i%2 == 1)
{
listBox1.Items.Add(i);
}
else if (i % 2 == 0)
{
listBox2.Items.Add(i);
}
}
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
}
}
Tidak ada komentar:
Posting Komentar