C#’ta Hesap Makinesi
Merhabalar… C#ta hesap makinesi yapımını beraber inceleyelim…
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
//Tanımlamalarımız.
int sayi1,sayi;
string isaret = “”;
bool isaret1;
public Form1()
{
InitializeComponent();
}
private void button10_Click(object sender, EventArgs e)
{
//Rakamların Girisi
//Rakam 0
if (isaret1 == true)
textBox1.Text = “0″;
else
if (textBox1.Text == “0″)
textBox1.Text = “0″;
else
textBox1.Text = textBox1.Text + “0″;
isaret1 = false;
}
private void button1_Click(object sender, EventArgs e)
{
//Rakam 1
if (isaret1 == true)
textBox1.Text = “1″;
else
if (textBox1.Text == “0″)
textBox1.Text = “1″;
else
textBox1.Text = textBox1.Text + “1″;
isaret1 = false;
}
private void button2_Click(object sender, EventArgs e)
{
//Rakam 2
if (isaret1 == true)
textBox1.Text = “2″;
else
if (textBox1.Text == “0″)
textBox1.Text = “2″;
else
textBox1.Text = textBox1.Text + “2″;
isaret1 = false;
}
private void button3_Click(object sender, EventArgs e)
{
//Rakam 3
if (isaret1 == true)
textBox1.Text = “3″;
else
if (textBox1.Text == “0″)
textBox1.Text = “3″;
else
textBox1.Text = textBox1.Text + “3″;
isaret1 = false;
}
private void button4_Click(object sender, EventArgs e)
{
//Rakam 4
if (isaret1 == true)
textBox1.Text = “4″;
else
if (textBox1.Text == “0″)
textBox1.Text = “4″;
else
textBox1.Text = textBox1.Text + “4″;
isaret1 = false;
}
private void button5_Click(object sender, EventArgs e)
{
//Rakam 5
if (isaret1 == true)
textBox1.Text = “5″;
else
if (textBox1.Text == “0″)
textBox1.Text = “5″;
else
textBox1.Text = textBox1.Text + “5″;
isaret1 = false;
}
private void button6_Click(object sender, EventArgs e)
{
//Rakam 6
if (isaret1 == true)
textBox1.Text = “6″;
else
if (textBox1.Text == “0″)
textBox1.Text = “6″;
else
textBox1.Text = textBox1.Text + “6″;
isaret1 = false;
}
private void button7_Click(object sender, EventArgs e)
{
//Rakam 7
if (isaret1 == true)
textBox1.Text = “7″;
else
if (textBox1.Text == “0″)
textBox1.Text = “7″;
else
textBox1.Text = textBox1.Text + “7″;
isaret1 = false;
}
private void button8_Click(object sender, EventArgs e)
{
//Rakam 8
if (isaret1 == true)
textBox1.Text = “8″;
else
if (textBox1.Text == “0″ )
textBox1.Text = “8″;
else
textBox1.Text = textBox1.Text + “8″;
isaret1 = false;
}
private void button9_Click(object sender, EventArgs e)
{
//Rakam 9
if (isaret1 == true)
textBox1.Text = “9″;
else
if (textBox1.Text == “0″ )
textBox1.Text = “9″;
else
textBox1.Text = textBox1.Text + “9″;
isaret1 = false;
}
private void button11_Click(object sender, EventArgs e)
{
//C ‘Yani Silme Butonumuz
isaret1 = false;
isaret = “”;
textBox1.Text = “0″;
}
private void button12_Click(object sender, EventArgs e)
{
//+ “Toplama” Butonumuz
if (isaret == “”)
sayi = Convert.ToInt32(textBox1.Text);
else
{
sayi1 = Convert.ToInt32(textBox1.Text);
if (isaret == “+”) { sayi = sayi + sayi1; textBox1.Text = Convert.ToString(sayi); }
}
isaret1 = true;
isaret = “+”;
}
private void button13_Click(object sender, EventArgs e)
{
//- “Çıkarma” Butonumuz
if (isaret == “”)
sayi = Convert.ToInt32(textBox1.Text);
else
{
sayi1 = Convert.ToInt32(textBox1.Text);
if (isaret == “-”) { sayi = sayi – sayi1; textBox1.Text = Convert.ToString(sayi); }
}
isaret1 = true;
isaret = “-”;
}
private void button14_Click(object sender, EventArgs e)
{
// * “Çarpma” Butonumuz
if (isaret == “”)
sayi = Convert.ToInt32(textBox1.Text);
else
{
sayi1 = Convert.ToInt32(textBox1.Text);
if (isaret == “*”) { sayi = sayi * sayi1; textBox1.Text = Convert.ToString(sayi); }
}
isaret1 = true;
isaret = “*”;
}
private void button15_Click(object sender, EventArgs e)
{
// / “Bölme” Butonumuz
if (isaret == “”)
sayi = Convert.ToInt32(textBox1.Text);
else
{
sayi1 = Convert.ToInt32(textBox1.Text);
if (isaret == “/”) { sayi = sayi / sayi1; textBox1.Text = Convert.ToString(sayi); }
}
isaret1 = true;
isaret = “/”;
}
private void button16_Click(object sender, EventArgs e)
{
// = “Eşittir” Butonumuz
isaret1 = true;
sayi1 = Convert.ToInt32(textBox1.Text);
if (isaret == “+”) { sayi = sayi + sayi1; textBox1.Text = Convert.ToString(sayi); }
if (isaret == “-”) { sayi = sayi – sayi1; textBox1.Text = Convert.ToString(sayi); }
if (isaret == “*”) { sayi = sayi * sayi1; textBox1.Text = Convert.ToString(sayi); }
if (isaret == “/”) { sayi = sayi / sayi1; textBox1.Text = Convert.ToString(sayi); }
}
}
}
Benzer Konularımıza da Göz Atın!
- C# ile Asal Sayılar
- C# 2-9 arası rakamlara bölünebilen sayılar(combobox)
- Foreach Döngüsü [C#]
- C# İki sayı arasındaki sayıların toplamı
- Sayısal Loto [C#]
- C#'ta işlemler
- C# Büyük Ünlü Uyumu
- Asansör Kontrol Programı [C#]
- c#'ta Celcius Ve Fahrenayt
- Visual Studio Menüleri - File Menüsü [C#]

bu programı gördüğümde ben bi garip hissediyom..10 saat bunla uğraşmıştık..:):)
Şefahat yine döktürmüş…:)
Evet Sema ugrastıkama bence ugrastıgımıza desmıs;) Fatıh yanlız degıldım:):)
orası öyle tabi de..anısı var yinede…:)
bool isaret1;
public Form1()
bool ve public in görevi nedir ?
Merhaba Bengü..
bool isaret1: derken;
Mesela bilinen bir tamsayının 10′dan daha büyük olup olmadığını veya bilinen bir string ifadenin “defter” kelimesiyle özdeş olup olmadığını bilmek çok kolaydır. C#’ta mantıksal bir veri tipi tanımlarken “bool” ifadesini kullanıyoruz. Bir tamsayıyı mantıksal bir değişkene atamaya çalışıyorsak 0 ya da 1 yerine “true” veya “false” anahtar kelimelerini yazarız. Yazılan örnektede “bool isaret1=false;” dur.
Public ise C#’ta örnek yaptığımızda kodların içinde bulunuyor
)
ÇOK TEŞEKKÜR EDERİM
Tansu Tesekkurler harıka acıklamıssın:):)
valla ya bn bile unutmuştum ne olduunun..tebrikler..:):)
Yardımcı olduysam ne mutlu bana
Bilgilerimizi paylaşmak için buradayız..
tansu gayet güzel anlatmışsın
Katılıyorum Tansuu..
resim geçen hafta değişikmiydi ben mi öyle hatırlıyorum
Evet değişikti düzenledim Bengü..:) Harika gözlemcisin:):)
ewd öyleyimdir çünkü geçen hafta butonlar dikkatimi çekti yapıyım dedim beceremedim acaba biraz yeniyim ondanmı diyorum ama neyse öğrenirim heralde süslü butonlar yapmayı
hımm olabilir neden olmasın Kolaydır c# Öğrendikçe de zevklidir;) en azından bana göre..
evet gerçekten öyle öğrendikçe güzelleşiyo okulda php den çok c# seviyorum arkadaşlarım bnm tam tersim..
kardes pekı bu hesap makınasını fortranda yazabılırmısın algorıtma ve flowchartı ıle bırlıkte eger yapabılırsn veya elınde hazır halı varsa bana mail atarsan cok sevınırım bu benım proje odevım sımdıden saygılar
mail adresim ceza_feyzal_ceza@hotmail.com
bool isaret1 değişkeni hangi amaçla tanımlanmıs?