Etiket Arşivi: C# Metotlarla Hesap Makinesi

C# Hesap Makinesi

C# Hesap Makinesi – Metotlarla Hesap Makinesi 

<span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
static void Ana (string [] args)</span></span>
{
Console.WriteLine("Bir sayı girin");<span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
int sayi1 = Convert.ToInt32 (Console.ReadLine ());</span></span>
Console.WriteLine("ikinci sayı girin");<span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
int sayi2 = Convert.ToInt32 (Console.ReadLine ());</span></span>
Console.WriteLine("Sembol Gir ---&gt; +, -, *, / ");
char sembol=Convert.ToChar(Console.ReadLine());
switch (sembol)<span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
{</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
davası '+':</span></span>
Console.WriteLine(toplama(sayi1, sayi2));<span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
kırılma;</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
durum '-':</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
Console.WriteLine (cıkarma (sayi1, sayi2));</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
kırılma;</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
durum '*':</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
Console.WriteLine (karpma (sayi1, sayi2));</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
kırılma;</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
durum '/':</span></span>
Console.WriteLine(bölme(sayi1,sayi2));<span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
kırılma;</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
varsayılan:</span></span>
Console.WriteLine("Lütfen Belirtilen Sembollerden Seçiniz");<span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
kırılma;</span></span>
}<span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
Console.ReadKey ();</span></span>
}
static int toplama (int sayi1,int sayi2)
{
int sonuc = 0;
sonuc = sayi1 + sayi2;
return sonuc;<span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
}</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
static int cıkarma (int sayi1, int sayi2)</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
{</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
int sonuc = 0;</span></span>
sonuc = sayi1 - sayi2;<span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
return sonuc;</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
}</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
static int carpma (int sayi1, int sayi2)</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
{</span></span>
int sonuc=0;
sonuc = sayi1 * sayi2;<span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
return sonuc;</span></span><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
}</span></span>
static double bölme (double sayi1,double sayi2)<span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
{</span></span>
double sonuc = 0;
sonuc = sayi1 / sayi2;<span style="vertical-align: inherit;"><span style="vertical-align: inherit;">
return sonuc;</span></span>
}