Membuat Aplikasi Kalkulator Sederhana menggunakan C# - Lanjutan Materi programming yang ini menjadi tugas saya awal pertama belajar bahasa C#.
KALKULATOR SEDERHANA
Berikut ini scriptnya :
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 TugasCalculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if ((textBox1.Text == "") || (textBox2.Text == ""))
{ MessageBox.Show("Masukkan angka : "); }
float a, b, c;
a = float.Parse(this.textBox1.Text);
b = float.Parse(this.textBox2.Text);
c = a + b;
this.textBox3.Text = Convert.ToString(c);
}
private void button2_Click(object sender, EventArgs e)
{
float a, b, c;
a = float.Parse(this.textBox1.Text);
b = float.Parse(this.textBox2.Text);
c = a - b;
this.textBox3.Text = Convert.ToString(c);
}
private void button3_Click(object sender, EventArgs e)
{
float a, b, c;
a = float.Parse(this.textBox1.Text);
b = float.Parse(this.textBox2.Text);
c = a * b;
this.textBox3.Text = Convert.ToString(c);
}
private void button4_Click(object sender, EventArgs e)
{
float a, b, c;
a = float.Parse(this.textBox1.Text);
b = float.Parse(this.textBox2.Text);
c = a / b;
this.textBox3.Text = Convert.ToString(c);
}
private void button5_Click(object sender, EventArgs e)
{
this.textBox1.Text = "";
this.textBox2.Text = "";
this.textBox3.Text = "";
}
}
}
Oke kawan selamat mencoba.
1 komentar:
keren
Berkomentar yang sopan ya, Terimakasih sahabat..
EmoticonEmoticon