Hoşgeldin Misafir

C# Vücut kitle indeksi hesaplayan program

MiRaT

13 Kas 2017
2,077 Mesaj

Aktiflik

Seviye

Deneyim

TIM / GÖREV:
Kod:
  double boy, kilo, sonuc;
        start:
            try
            { 
            
                Console.Title = "Vücut Kitle indeksi Hesaplama";
                Console.WriteLine("");
                Console.Write("Boyunuzu giriniz. (boyunuzu metre cinsinden giriniz. örn: 1,75): ");
                boy = Convert.ToDouble(Console.ReadLine());
                Console.WriteLine("");
                Console.Write("Kilonuzu giriniz (örn: 70,50): ");
                kilo = Convert.ToDouble(Console.ReadLine());
                Console.WriteLine("");
                sonuc = kilo / (boy * boy);
                Console.WriteLine("Vücut kitle indeksiniz: {0}", Math.Round(sonuc));

                if (sonuc <= 18.4)
                {
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("0 - 18,4: Zayıf");

                }

                else if (sonuc >= 18.5 && sonuc <= 24.9)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("18,5 - 24,9: Normal");

                }
                else if (sonuc >= 25.0 && sonuc <= 29.9)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("25,0 - 29,9: Fazla Kilolu");
                }
                else if (sonuc >= 30.0 && sonuc <= 34.9)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("30,0 - 34,9: Şişman (Obez) - I. Sınıf");
                }
                else if (sonuc >= 35.0 && sonuc <= 44.9)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("35,0 - 44,9: Şişman (Obez) - II. Sınıf");
                }
                else if (sonuc >= 45.0)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("45,0 ve üstü: Aşırı Şişman (Aşırı Obez) - III. Sınıf");

                }
            }
            catch {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("program beklenmedik bir hata ile karşılaştı.");
                    Console.ForegroundColor = ConsoleColor.Gray;
                goto start;
            }
            Console.ReadKey();