1. Anasayfa
  2. Programlama Temelleri

C# Örnekleri-İç içe if Kullanımı

C# Örnekleri-İç içe if Kullanımı
2


Kullanıcı tarafından girilen üç sayıdan en büyük ile en küçük sayıyı toplayıp ortanca sayıyı çıkaran program?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
int s1, s2, s3, buyuk, kucuk,ortanca;
            Console.Write("Birinci sayıyı girin");
            s1 = Convert.ToInt32(Console.ReadLine());
            Console.Write("İkinci sayıyı girin");
            s2 = Convert.ToInt32(Console.ReadLine());
            Console.Write("Üçüncü sayıyı girin");
            s3 = Convert.ToInt32(Console.ReadLine());
            if (s1 > s2 && s1 > s3)
                buyuk = s1;
            else if (s2 > s1 && s2 > s3)
                buyuk = s2;
            else
                buyuk = s3;
 
            if (s1 < s2 && s1 < s3)
                kucuk = s1;
            else if (s2 < s1 && s2 < s3)
                kucuk = s2;
            else
                kucuk = s3;
            if (s1 < s2 && s2 < s3)
                ortanca = s2;
            else if (s2 < s1 && s1< s3)
                ortanca = s1;
            else
                ortanca = s3;
            Console.WriteLine("Sonuç" + ((kucuk + buyuk)-ortanca));
            Console.ReadLine();

Girilen iki notun ortalamasını alıp hangi dereceyle gectiğini veya kaldığını bulan program?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int not1, not2, ort;
           Console.WriteLine("1.notu giriniz=");
           not1 = Convert.ToInt32(Console.ReadLine());
           Console.WriteLine("2.notu giriniz=");
           not2 = Convert.ToInt32(Console.ReadLine());
           ort = (not1 + not2) / 2;
           if (ort <= 49)
               Console.WriteLine("kalır");
           else if (ort <= 50)//http://www.bilisimogretmeni.com
               Console.WriteLine("geçer");
           else if (ort <= 60)
               Console.WriteLine("orta");
           else if (ort <= 80)
               Console.WriteLine("iyi");
           else if (ort >= 85)
               Console.WriteLine("pek iyi");
           Console.ReadKey();

Girilen değerin sıfırmı,pozitifmi veya negatifmi olduğunu bulan program?

1
2
3
4
5
6
7
8
9
10
11
12
13
int sayi;
           Console.Write("Lütfen bir sayı giriniz = ");
           sayi=Convert.ToInt32(Console.ReadLine());
           if (sayi == 0)
            Console.WriteLine("Girilen sayı sıfırdır");
          else if (sayi < 0)
          Console.WriteLine("Girilen sayı negatiftir");
          else if (sayi > 0)
          Console.WriteLine("Girilen sayı pozitiftir");
         else
          Console.WriteLine("HATA !!!");
          //http://www.bilisimogretmeni.com
          Console.ReadKey();

Bir firmadan herhangi bir servis paketi almak isteyen bir müşterinin bütçesinin bu servis için uygun olup olmadığını kontrol edeceğiz.

Bu firma 2 adet servis paketi sunuyor ve herhangi bir paketi alabilmek için müşterinin bütçesinin en az 1500 TL olması gerekiyor. Müşterinin bütçesi 1500 ile 2500 TL arasında ise A pakedini, 2500 TL ve daha fazla ise hem daha düşük tutarda olan A paketini hem de bir üst paket olan B paketini alabiliyor.

1
2
3
4
5
6
7
8
9
10
11
12
13
int butce;
           Console.WriteLine("Bütçenizi Girin");
           butce = Convert.ToInt32(Console.ReadLine());
           if (butce >= 1500)
           {
               if (butce >= 1500 && butce < 2500)
                   Console.WriteLine("A PAKETİ");
               else if (butce >= 2500)
                   Console.WriteLine("A PAKETİ VE B PAKETİ");
           }//http://www.bilisimogretmeni.com/
           else
               Console.WriteLine("Bütçe 1500'den az");
           Console.ReadKey();

Girilen Emlak türü ve Satın alma ve kiralama bilgisi ve bütçe bilgilerine göre kontrol işlemi yapan program

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
string tercih,tercih2,tercih3;
int butce, butce2;
Console.WriteLine("1-Daire");
Console.WriteLine("2-Villa");
Console.Write("Seçiminiz (1-2) : ");
tercih = Console.ReadLine();
if (tercih == "1")
{
  
Console.WriteLine("3-Satilik Daire");
Console.WriteLine("4-Kiralik Daire");
Console.Write("Seçiminiz (3-4) : ");
tercih2 = Console.ReadLine();
if (tercih2 == "3")
{
Console.WriteLine("Butceniz");
butce = Convert.ToInt32(Console.ReadLine());
  
if (butce >= 50000)
Console.WriteLine("Bu daireyi satin alabilirsin");
else Console.WriteLine("bu daireyi satin alamassın");
}
if (tercih2 == "4")
{
Console.WriteLine("Butceniz");
butce2 = Convert.ToInt32(Console.ReadLine());
if (butce2 >= 500)
Console.WriteLine("Bu Daireyi Kiralayabilirsiniz");
else Console.WriteLine("bu Daireyi Kiralayamassiniz");
}
}
//Villa baslangici
if (tercih == "2")
{
Console.WriteLine("5-Satilik Villa");
Console.WriteLine("6-Kiralik Villa");
Console.Write("Seçiminiz (5-6) : ");
tercih3 = Console.ReadLine();
if (tercih3 == "5")
{
Console.WriteLine("Butceniz");
butce = Convert.ToInt32(Console.ReadLine());
  
if (butce >= 500000)
Console.WriteLine("Bu Villayi Satin Alabilirsin");
else Console.WriteLine("Bu villayi Satin Alamassiniz");
}
if (tercih == "2")
{
Console.WriteLine("Butceniz");
butce2 = Convert.ToInt32(Console.ReadLine());
if (butce2 >= 5000)
Console.WriteLine("Bu Villayı Kiralayabilirsiniz");
else Console.WriteLine("Bu Villayı Kiralayamassiniz");
}
}
Console.ReadKey();

Girilen sıcaklık bilgisine göre hava durumunu değerlendiren program

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int s;
Console.WriteLine(“Hava sıcaklığını giriniz..:”);
s = Convert.ToInt16(Console.ReadLine());
 
if (s > -50 && s < 0)
{
Console.WriteLine(“Çok soğuk”);
}
else if (s > 0 && s < 10)
{
Console.WriteLine(“ılık”);
}
else if (s > 10 && s < 20)
{
Console.WriteLine(“sıcak”);
}
else
{
Console.WriteLine(“çok sıcak”);
}
Console.ReadKey();
Bu İçeriğe Tepkin Ne Oldu?
  • 15
    ba_ar_l_
    Başarılı
  • 7
    gayet_yi
    Gayet İyi
  • 3
    te_ekk_rler
    Teşekkürler
  • 3
    anlamad_m
    Anlamadım
  • 10
    yetersiz
    Yetersiz
Subscribe
Bildir
guest


Bu site, istenmeyenleri azaltmak için Akismet kullanıyor. Yorum verilerinizin nasıl işlendiği hakkında daha fazla bilgi edinin.

2 Yorum
Inline Feedbacks
View all comments

valla hıc anlaamıyommmm

Mehmet Ali Çakmak

çok güzel oldu