using System;
using
System.Drawing;
using
System.Collections;
using
System.ComponentModel;
using
System.Windows.Forms;
using
System.Data;
namespace HesMak
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class HesapMak : System.Windows.Forms.Form
{
private
System.Windows.Forms.TextBox sonuc;
private
System.Windows.Forms.Button c;
private
System.Windows.Forms.Button yedi;
private
System.Windows.Forms.Button sekiz;
private
System.Windows.Forms.Button dokuz;
private
System.Windows.Forms.Button dort;
private
System.Windows.Forms.Button bes;
private
System.Windows.Forms.Button alti;
private
System.Windows.Forms.Button bir;
private
System.Windows.Forms.Button iki;
private
System.Windows.Forms.Button uc;
private
System.Windows.Forms.Button sifir;
private
System.Windows.Forms.Button carpma;
private
System.Windows.Forms.Button us;
private
System.Windows.Forms.Button bolme;
private
System.Windows.Forms.Button log;
private
System.Windows.Forms.Button toplama;
private
System.Windows.Forms.Button isaret;
private
System.Windows.Forms.Button nokta;
private
System.Windows.Forms.Button cikarma;
private
System.Windows.Forms.Button esittir;
private
System.Windows.Forms.Button reset;
private
System.Windows.Forms.Button kare;
bool
sonbasilan,nokt;
//bool ex;
double
ilk;
int
sonislemno;
/// <summary>
/// Required designer variable.
/// </summary>
private
System.ComponentModel.Container components = null;
public
HesapMak()
{
sonbasilan=false;
nokt=false;
//ex=false;
sonislemno=0;
ilk=0.0;
//
//
Required for Windows Form Designer support
//
InitializeComponent();
//
//
TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected
override void
Dispose( bool disposing )
{
if(
disposing )
{
if
(components != null)
{
components.Dispose();
}
}
base.Dispose(
disposing );
}
#region Windows
Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private
void InitializeComponent()
{
this.sonuc
= new System.Windows.Forms.TextBox();
this.reset
= new System.Windows.Forms.Button();
this.c
= new System.Windows.Forms.Button();
this.yedi
= new System.Windows.Forms.Button();
this.sekiz
= new System.Windows.Forms.Button();
this.dokuz
= new System.Windows.Forms.Button();
this.carpma
= new System.Windows.Forms.Button();
this.us
= new System.Windows.Forms.Button();
this.dort
= new System.Windows.Forms.Button();
this.bes
= new System.Windows.Forms.Button();
this.alti
= new System.Windows.Forms.Button();
this.bolme
= new System.Windows.Forms.Button();
this.log
= new System.Windows.Forms.Button();
this.bir
= new System.Windows.Forms.Button();
this.iki
= new System.Windows.Forms.Button();
this.uc
= new System.Windows.Forms.Button();
this.toplama
= new System.Windows.Forms.Button();
this.kare
= new System.Windows.Forms.Button();
this.isaret
= new System.Windows.Forms.Button();
this.sifir
= new System.Windows.Forms.Button();
this.nokta
= new System.Windows.Forms.Button();
this.cikarma
= new System.Windows.Forms.Button();
this.esittir
= new System.Windows.Forms.Button();
this.SuspendLayout();
//
//
sonuc
//
this.sonuc.Location
= new System.Drawing.Point(32, 32);
this.sonuc.Name
= "sonuc";
this.sonuc.Size
= new System.Drawing.Size(304, 20);
this.sonuc.TabIndex
= 0;
this.sonuc.Text
= "0";
this.sonuc.TextAlign
= System.Windows.Forms.HorizontalAlignment.Right;
this.sonuc.TextChanged += new
System.EventHandler(this.sonuc_TextChanged);
//
//
reset
//
this.reset.Location
= new System.Drawing.Point(224, 80);
this.reset.Name
= "reset";
this.reset.Size
= new System.Drawing.Size(48, 32);
this.reset.TabIndex
= 1;
this.reset.Text
= "Reset";
this.reset.Click
+= new System.EventHandler(this.reset_Click);
//
// c
//
this.c.Location
= new System.Drawing.Point(288, 80);
this.c.Name
= "c";
this.c.Size
= new System.Drawing.Size(48, 32);
this.c.TabIndex
= 2;
this.c.Text
= "C";
//
//
yedi
//
this.yedi.Location
= new System.Drawing.Point(32, 136);
this.yedi.Name
= "yedi";
this.yedi.Size
= new System.Drawing.Size(48, 32);
this.yedi.TabIndex
= 3;
this.yedi.Text
= "7";
this.yedi.Click
+= new System.EventHandler(this.yedi_Click);
//
//
sekiz
//
this.sekiz.Location
= new System.Drawing.Point(96, 136);
this.sekiz.Name
= "sekiz";
this.sekiz.Size
= new System.Drawing.Size(48, 32);
this.sekiz.TabIndex
= 4;
this.sekiz.Text
= "8";
this.sekiz.Click
+= new System.EventHandler(this.sekiz_Click);
//
//
dokuz
//
this.dokuz.Location
= new System.Drawing.Point(160, 136);
this.dokuz.Name
= "dokuz";
this.dokuz.Size
= new System.Drawing.Size(48, 32);
this.dokuz.TabIndex
= 5;
this.dokuz.Text
= "9";
this.dokuz.Click
+= new System.EventHandler(this.dokuz_Click);
//
//
carpma
//
this.carpma.Location
= new System.Drawing.Point(224, 136);
this.carpma.Name
= "carpma";
this.carpma.Size
= new System.Drawing.Size(48, 32);
this.carpma.TabIndex
= 6;
this.carpma.Text
= "*";
this.carpma.Click
+= new System.EventHandler(this.carpma_Click);
//
//
us
//
this.us.Location
= new System.Drawing.Point(288, 136);
this.us.Name
= "us";
this.us.Size
= new System.Drawing.Size(48, 32);
this.us.TabIndex
= 7;
this.us.Text
= "Us";
this.us.Click
+= new System.EventHandler(this.us_Click);
//
//
dort
//
this.dort.Location
= new System.Drawing.Point(32, 184);
this.dort.Name
= "dort";
this.dort.Size
= new System.Drawing.Size(48, 32);
this.dort.TabIndex
= 8;
this.dort.Text
= "4";
this.dort.Click
+= new System.EventHandler(this.dort_Click);
//
//
bes
//
this.bes.Location
= new System.Drawing.Point(96, 184);
this.bes.Name
= "bes";
this.bes.Size
= new System.Drawing.Size(48, 32);
this.bes.TabIndex
= 9;
this.bes.Text
= "5";
this.bes.Click
+= new System.EventHandler(this.bes_Click);
//
// alti
//
this.alti.Location
= new System.Drawing.Point(160, 184);
this.alti.Name
= "alti";
this.alti.Size
= new System.Drawing.Size(48, 32);
this.alti.TabIndex
= 10;
this.alti.Text
= "6";
this.alti.Click
+= new System.EventHandler(this.alti_Click);
//
//
bolme
//
this.bolme.Location
= new System.Drawing.Point(224, 184);
this.bolme.Name
= "bolme";
this.bolme.Size
= new System.Drawing.Size(48, 32);
this.bolme.TabIndex
= 11;
this.bolme.Text
= "/";
this.bolme.Click
+= new System.EventHandler(this.bolme_Click);
//
//
log
//
this.log.Location
= new System.Drawing.Point(288, 184);
this.log.Name
= "log";
this.log.Size
= new System.Drawing.Size(48, 32);
this.log.TabIndex
= 12;
this.log.Text
= "log";
this.log.Click
+= new System.EventHandler(this.log_Click);
//
//
bir
//
this.bir.Location
= new System.Drawing.Point(32, 232);
this.bir.Name
= "bir";
this.bir.Size
= new System.Drawing.Size(48, 32);
this.bir.TabIndex
= 13;
this.bir.Text
= "1";
this.bir.Click
+= new System.EventHandler(this.bir_Click);
//
//
iki
//
this.iki.Location
= new System.Drawing.Point(96, 232);
this.iki.Name
= "iki";
this.iki.Size
= new System.Drawing.Size(48, 32);
this.iki.TabIndex
= 14;
this.iki.Text
= "2";
this.iki.Click
+= new System.EventHandler(this.iki_Click);
//
//
uc
//
this.uc.Location
= new System.Drawing.Point(160, 232);
this.uc.Name
= "uc";
this.uc.Size
= new System.Drawing.Size(48, 32);
this.uc.TabIndex
= 15;
this.uc.Text
= "3";
this.uc.Click
+= new System.EventHandler(this.uc_Click);
//
//
toplama
//
this.toplama.Location
= new System.Drawing.Point(224, 232);
this.toplama.Name
= "toplama";
this.toplama.Size
= new System.Drawing.Size(48, 32);
this.toplama.TabIndex
= 16;
this.toplama.Text
= "+";
this.toplama.Click
+= new System.EventHandler(this.toplama_Click);
//
//
kare
//
this.kare.Location
= new System.Drawing.Point(288, 232);
this.kare.Name
= "kare";
this.kare.Size
= new System.Drawing.Size(48, 32);
this.kare.TabIndex
= 17;
this.kare.Text
= "Kare";
this.kare.Click
+= new System.EventHandler(this.kare_Click);
//
//
isaret
//
this.isaret.Location
= new System.Drawing.Point(32, 280);
this.isaret.Name
= "isaret";
this.isaret.Size
= new System.Drawing.Size(48, 32);
this.isaret.TabIndex
= 18;
this.isaret.Text
= "+/-";
this.isaret.Click
+= new System.EventHandler(this.isaret_Click);
//
// sifir
//
this.sifir.Location
= new System.Drawing.Point(96, 280);
this.sifir.Name
= "sifir";
this.sifir.Size
= new System.Drawing.Size(48, 32);
this.sifir.TabIndex
= 19;
this.sifir.Text
= "0";
this.sifir.Click
+= new System.EventHandler(this.sifir_Click);
//
//
nokta
//
this.nokta.Location
= new System.Drawing.Point(160, 280);
this.nokta.Name
= "nokta";
this.nokta.Size
= new System.Drawing.Size(48, 32);
this.nokta.TabIndex
= 20;
this.nokta.Text
= ".";
this.nokta.Click
+= new System.EventHandler(this.nokta_Click);
//
//
cikarma
//
this.cikarma.Location
= new System.Drawing.Point(224, 280);
this.cikarma.Name
= "cikarma";
this.cikarma.Size
= new System.Drawing.Size(48, 32);
this.cikarma.TabIndex
= 21;
this.cikarma.Text
= "-";
this.cikarma.Click
+= new System.EventHandler(this.cikarma_Click);
//
//
esittir
//
this.esittir.Location
= new System.Drawing.Point(288, 280);
this.esittir.Name
= "esittir";
this.esittir.Size
= new System.Drawing.Size(48, 32);
this.esittir.TabIndex
= 22;
this.esittir.Text
= "=";
this.esittir.Click
+= new System.EventHandler(this.esittir_Click);
//
//
HesapMak
//
this.AutoScaleBaseSize
= new System.Drawing.Size(5, 13);
this.ClientSize = new
System.Drawing.Size(368, 334);
this.Controls.Add(this.esittir);
this.Controls.Add(this.cikarma);
this.Controls.Add(this.nokta);
this.Controls.Add(this.sifir);
this.Controls.Add(this.isaret);
this.Controls.Add(this.kare);
this.Controls.Add(this.toplama);
this.Controls.Add(this.uc);
this.Controls.Add(this.iki);
this.Controls.Add(this.bir);
this.Controls.Add(this.log);
this.Controls.Add(this.bolme);
this.Controls.Add(this.alti);
this.Controls.Add(this.bes);
this.Controls.Add(this.dort);
this.Controls.Add(this.us);
this.Controls.Add(this.carpma);
this.Controls.Add(this.dokuz);
this.Controls.Add(this.sekiz);
this.Controls.Add(this.yedi);
this.Controls.Add(this.c);
this.Controls.Add(this.reset);
this.Controls.Add(this.sonuc);
this.Name
= "HesapMak";
this.Text
= "Hesap Makinesi";
this.Load
+= new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static
void Main()
{
Application.Run(new HesapMak());
}
private
void sonuc_TextChanged(object
sender, System.EventArgs e)
{
}
private
void Form1_Load(object
sender, System.EventArgs e)
{
}
private
void sekiz_Click(object
sender, System.EventArgs e)
{
if(sonbasilan)
{
sonuc.Text=""+8;
sonbasilan=false;
}
else
if(!sonuc.Text.Equals("0"))
sonuc.Text=sonuc.Text+"8";
else
if(true)
sonuc.Text=""+"8";
//if(ex)
// ex=false;
}
private
void yedi_Click(object
sender, System.EventArgs e)
{
if(sonbasilan)
{
sonuc.Text=""+"7";
sonbasilan=false;
}
else
if(!sonuc.Text.Equals("0"))
sonuc.Text=sonuc.Text+"7";
else
if(true)
sonuc.Text=""+"7";
//if(ex)
// ex=false;
}
private
void bir_Click(object
sender, System.EventArgs e)
{
if(sonbasilan)
{
sonuc.Text=""+1;
sonbasilan=false;
}
else
if(!sonuc.Text.Equals("0"))
sonuc.Text=sonuc.Text+"1";
else
if(true)
sonuc.Text=""+"1";
//if(ex)
// ex=false;
}
private
void iki_Click(object
sender, System.EventArgs e)
{
if(sonbasilan)
{
sonuc.Text=""+2;
sonbasilan=false;
}
else
if(!sonuc.Text.Equals("0"))
sonuc.Text=sonuc.Text+"2";
else
if(true)
sonuc.Text=""+"2";
//if(ex)
// ex=false;
}
private
void uc_Click(object
sender, System.EventArgs e)
{
if(sonbasilan)
{
sonuc.Text=""+3;
sonbasilan=false;
}
else
if(!sonuc.Text.Equals("0"))
sonuc.Text=sonuc.Text+"3";
else
if(true)
sonuc.Text=""+"3";
//if(ex)
// ex=false;
}
private
void dort_Click(object
sender, System.EventArgs e)
{
if(sonbasilan)
{
sonuc.Text=""+4;
sonbasilan=false;
}
else
if(!sonuc.Text.Equals("0"))
sonuc.Text=sonuc.Text+"4";
else
if(true)
sonuc.Text=""+"4";
//if(ex)
// ex=false;
}
private
void bes_Click(object
sender, System.EventArgs e)
{
if(sonbasilan)
{
sonuc.Text=""+5;
sonbasilan=false;
}
else
if(!sonuc.Text.Equals("0"))
sonuc.Text=sonuc.Text+"5";
else
if(true)
sonuc.Text=""+"5";
//if(ex)
// ex=false;
}
private
void alti_Click(object
sender, System.EventArgs e)
{
if(sonbasilan)
{
sonuc.Text=""+6;
sonbasilan=false;
}
else
if(!sonuc.Text.Equals("0"))
sonuc.Text=sonuc.Text+"6";
else
if(true)
sonuc.Text=""+"6";
//if(ex)
// ex=false;
}
private
void dokuz_Click(object
sender, System.EventArgs e)
{
if(sonbasilan)
{
sonuc.Text=""+9;
sonbasilan=false;
}
else
if(!sonuc.Text.Equals("0"))
sonuc.Text=sonuc.Text+"9";
else
if(true)
sonuc.Text=""+"9";
//if(ex)
//ex=false;
}
private
void sifir_Click(object
sender, System.EventArgs e)
{
if(sonbasilan)
{
sonuc.Text=""+0;
sonbasilan=false;
}
else
if(!sonuc.Text.Equals("0"))
sonuc.Text=sonuc.Text+"0";
else
if(true)
sonuc.Text=""+"0";
//if(ex)
//ex=false;
}
private
void reset_Click(object
sender, System.EventArgs e)
{
sonuc.Text="0";
sonbasilan=false;
nokt=false;
sonislemno=0;
ilk=0;
//ex=false;
}
private
void nokta_Click(object
sender, System.EventArgs e)
{
if(!nokt)
{
if(sonbasilan)
sonuc.Text="0.";
else
sonuc.Text=sonuc.Text+".";
nokt=true;
sonbasilan=false;
//if(ex)
// ex=false;
}
}
private
void isaret_Click(object
sender, System.EventArgs e)
{
//if(!ex)
//{
double
x=Convert.ToDouble(sonuc.Text);
if(x!=0.0)
{
x*=-1;
sonuc.Text=""+x;
}
//}
}
private
void toplama_Click(object
sender, System.EventArgs e)
{
//if(!ex)
//{
if(sonislemno==0
|| sonbasilan)
{
ilk=Convert.ToDouble(sonuc.Text);
sonislemno=3;
sonbasilan=true;
nokt=false;
}
else
islemYap(3);
//}
}
private
void cikarma_Click(object
sender, System.EventArgs e)
{
//if(!ex)
//{
if(sonislemno==0
|| sonbasilan)
{
ilk=Convert.ToDouble(sonuc.Text);
sonislemno=4;
sonbasilan=true;
nokt=false;
}
else
islemYap(4);
//}
}
private
void carpma_Click(object
sender, System.EventArgs e)
{
//if(!ex)
//{
if(sonislemno==0
|| sonbasilan)
{
ilk=Convert.ToDouble(sonuc.Text);
sonislemno=1;
sonbasilan=true;
nokt=false;
}
else
islemYap(1);
//}
}
private
void bolme_Click(object
sender, System.EventArgs e)
{
//if(!ex)
//{
if(sonislemno==0
|| sonbasilan)
{
ilk=Convert.ToDouble(sonuc.Text);
sonislemno=2;
sonbasilan=true;
nokt=false;
}
else
islemYap(2);
//}
}
private
void us_Click(object
sender, System.EventArgs e)
{
//if(!ex)
//{
if(sonislemno==0
|| sonbasilan)
{
ilk=Convert.ToDouble(sonuc.Text);
sonislemno=5;
sonbasilan=true;
nokt=false;
}
else
islemYap(5);
//}
}
private
void log_Click(object
sender, System.EventArgs e)
{
//if(!ex)
//{
if(sonislemno==0
|| sonbasilan)
{
double x=Convert.ToDouble(sonuc.Text);
if(x<0.0)
{
//negatifse islem yapmaz
}
else
{
sonuc.Text=""+Math.Log(x);
sonislemno=0;
sonbasilan=true;
nokt=false;
}
}
else
islemYap(0);
//}
}
private
void kare_Click(object
sender, System.EventArgs e)
{
//if(!ex)
//{
if(sonislemno==0
|| sonbasilan)
{
double x=Convert.ToDouble(sonuc.Text);
sonuc.Text=""+(x*x);
sonislemno=0;
sonbasilan=true;
nokt=false;
}
else
islemYap(0);
//}
}
private
void esittir_Click(object
sender, System.EventArgs e)
{
//if(!ex)
//{
if(sonislemno>0)
islemYap(0);
else
{
sonbasilan=true;
nokt=false;
}
//}
}
private
double toplamaIslemi(double
a,double b)
{
return
(a+b);
}
private
double cikarmaIslemi(double
a,double b)
{
return
(a-b);
}
private
double carpmaIslemi(double
a,double b)
{
return
(a*b);
}
private
double bolmeIslemi(double
a,double b)
{
return
(a/b);
}
private
double kuvvetIslemi(double
a,double b)
{
return
Math.Pow(a,b);
}
private
void islemYap(int
islem)
{
if(sonislemno==1)
{
double
iki=Convert.ToDouble(sonuc.Text);
sonuc.Text=""+carpmaIslemi(ilk,iki);
sonislemno=islem;
sonbasilan=true;
nokt=false;
ilk=0.0;
}
else
if(sonislemno==2)
{
double
iki=Convert.ToDouble(sonuc.Text);
if(iki==0.0)
{
//hata ver,0 a bolme hatasiii,sifirla
}
else
{
sonuc.Text=""+bolmeIslemi(ilk,iki);
sonislemno=islem;
sonbasilan=true;
nokt=false;
ilk=0.0;
}
}
else
if(sonislemno==3)
{
double
iki=Convert.ToDouble(sonuc.Text);
sonuc.Text=""+toplamaIslemi(ilk,iki);
sonislemno=islem;
sonbasilan=true;
nokt=false;
ilk=0.0;
}
else
if(sonislemno==4)
{
double
iki=Convert.ToDouble(sonuc.Text);
sonuc.Text=""+cikarmaIslemi(ilk,iki);
sonislemno=islem;
sonbasilan=true;
nokt=false;
ilk=0.0;
}
else
if(sonislemno==5)
{
double
iki=Convert.ToDouble(sonuc.Text);
sonuc.Text=""+kuvvetIslemi(ilk,iki);
sonislemno=islem;
sonbasilan=true;
nokt=false;
ilk=0.0;
}
if(islem>0)
ilk=Convert.ToDouble(sonuc.Text);
}
}
}