Basit kodlarla bilgisayardaki hesap makinası yapımını görelim.
Basit kodlarla bilgisayardaki hesap makinası yapımını görelim.
[Resimleri görebilmek için üye olun veya giriş yapın.]
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 hesap_makinası
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double sayi1;
double sayi2;
double sayi3;
char islem;
private void button10_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "0";
}
private void button7_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "1";
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button8_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "2";
}
private void button9_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "3";
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "4";
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "5";
}
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "6";
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "7";
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "8";
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "9";
}
private void button16_Click(object sender, EventArgs e)
{
string deger = textBox1.Text;
textBox1.Text = "";
sayi1 = Convert.ToInt32(deger);
islem='+';
}
private void button20_Click(object sender, EventArgs e)
{
if(sayi2!=null)
{
string deger2 = textBox1.Text;
textBox1.Text = "";
sayi2 = Convert.ToInt32(deger2);
if (islem == '*')
{
double sonuc = sayi1 * sayi2;
textBox1.Text = sonuc.ToString();
}
if (islem == '+')
{
double sonuc = sayi1 + sayi2;
textBox1.Text = sonuc.ToString();
}
if (islem == '-')
{
double sonuc = sayi1 - sayi2;
textBox1.Text = sonuc.ToString();
}
if (islem == '/')
{
double bolme = sayi1 / sayi2;
textBox1.Text = Convert.ToString(bolme);
}
if (islem == '%')
{
double sonuc = sayi1 * sayi2 / 100;
textBox1.Text = sonuc.ToString();
}
}
}
private void button17_Click(object sender, EventArgs e)
{
double deger = Convert.ToDouble(textBox1.Text);
double koksonuc = Math.Sqrt(deger);
textBox1.Text = koksonuc.ToString();
}
private void button14_Click(object sender, EventArgs e)
{
string deger = textBox1.Text;
textBox1.Text = "";
sayi1 = Convert.ToInt32(deger);
islem = '*';
}
private void button15_Click(object sender, EventArgs e)
{
string deger = textBox1.Text;
textBox1.Text = "";
sayi1 = Convert.ToInt32(deger);
islem = '-';
}
private void button13_Click(object sender, EventArgs e)
{
string deger = textBox1.Text;
textBox1.Text = "";
sayi1 = Convert.ToInt32(deger);
islem = '/';
}
private void button18_Click(object sender, EventArgs e)
{
string deger = textBox1.Text;
textBox1.Text = "";
sayi1 = Convert.ToInt32(deger);
islem = '%';
}
private void button25_Click(object sender, EventArgs e)
{
textBox1.Text = "";
}
private void button24_Click(object sender, EventArgs e)
{
}
private void button11_Click(object sender, EventArgs e)
{
double sayi =Double.Parse( textBox1.Text);
sayi = sayi * -1;
textBox1.Text = sayi.ToString();
}
private void button22_Click(object sender, EventArgs e)
{
}
}
}
[Linkleri görebilmek için üye olun veya giriş yapın.]
[Resimleri görebilmek için üye olun veya giriş yapın.]
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 hesap_makinası
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double sayi1;
double sayi2;
double sayi3;
char islem;
private void button10_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "0";
}
private void button7_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "1";
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button8_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "2";
}
private void button9_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "3";
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "4";
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "5";
}
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "6";
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "7";
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "8";
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "9";
}
private void button16_Click(object sender, EventArgs e)
{
string deger = textBox1.Text;
textBox1.Text = "";
sayi1 = Convert.ToInt32(deger);
islem='+';
}
private void button20_Click(object sender, EventArgs e)
{
if(sayi2!=null)
{
string deger2 = textBox1.Text;
textBox1.Text = "";
sayi2 = Convert.ToInt32(deger2);
if (islem == '*')
{
double sonuc = sayi1 * sayi2;
textBox1.Text = sonuc.ToString();
}
if (islem == '+')
{
double sonuc = sayi1 + sayi2;
textBox1.Text = sonuc.ToString();
}
if (islem == '-')
{
double sonuc = sayi1 - sayi2;
textBox1.Text = sonuc.ToString();
}
if (islem == '/')
{
double bolme = sayi1 / sayi2;
textBox1.Text = Convert.ToString(bolme);
}
if (islem == '%')
{
double sonuc = sayi1 * sayi2 / 100;
textBox1.Text = sonuc.ToString();
}
}
}
private void button17_Click(object sender, EventArgs e)
{
double deger = Convert.ToDouble(textBox1.Text);
double koksonuc = Math.Sqrt(deger);
textBox1.Text = koksonuc.ToString();
}
private void button14_Click(object sender, EventArgs e)
{
string deger = textBox1.Text;
textBox1.Text = "";
sayi1 = Convert.ToInt32(deger);
islem = '*';
}
private void button15_Click(object sender, EventArgs e)
{
string deger = textBox1.Text;
textBox1.Text = "";
sayi1 = Convert.ToInt32(deger);
islem = '-';
}
private void button13_Click(object sender, EventArgs e)
{
string deger = textBox1.Text;
textBox1.Text = "";
sayi1 = Convert.ToInt32(deger);
islem = '/';
}
private void button18_Click(object sender, EventArgs e)
{
string deger = textBox1.Text;
textBox1.Text = "";
sayi1 = Convert.ToInt32(deger);
islem = '%';
}
private void button25_Click(object sender, EventArgs e)
{
textBox1.Text = "";
}
private void button24_Click(object sender, EventArgs e)
{
}
private void button11_Click(object sender, EventArgs e)
{
double sayi =Double.Parse( textBox1.Text);
sayi = sayi * -1;
textBox1.Text = sayi.ToString();
}
private void button22_Click(object sender, EventArgs e)
{
}
}
}
[Linkleri görebilmek için üye olun veya giriş yapın.]