Çok doğruharika bir dildir
boy'da cm yerine metre kullanılıyormuş bir bakmanı öneririmCihaz.
Mesaj otomatik birleştirildi:
using System;
namespace MyApp // Note: ****** namespace depends on the project name.
{
internal class Program
{
static void Main(string[] args)
{
int yas, kilo=0, boy=0;
Boolean devam = true;
int devam2 = 1;
Console.WriteLine("Lütfen yasinizi giriniz");
yas =Convert.ToInt32(Console.ReadLine());
Console.WriteLine(yas);
try
{
do
{
if (yas >= 20)
{
Console.WriteLine("Lütfen kilo giriniz");
string giris1 = Console.ReadLine();
Console.WriteLine("Lütfen boy giriniz");
string giris2 =Console.ReadLine();
Console.WriteLine(VKIHesaplama(kilo, boy));
if(int.TryParse(giris2, out boy)&&int.TryParse(giris1, out kilo))
{
}
else
{
Console.WriteLine("Dogru formatta giriniz");
}
Console.WriteLine("Devam etmek istiyor musunuz? 1-Evet 2-Hayır");
devam2 =Convert.ToInt32(Console.ReadLine());
switch (devam2)
{
case 1: devam = true; break;
case 2: devam = false; break;
}
}
else
Console.WriteLine("Yas 20 ve üstü olmalıdır tekrar giriniz.");
} while (devam);
}
catch (FormatException hata)
{
Console.WriteLine("Yanlış formatta değer girildi tekrar giriniz.");
}
catch (Exception)
{
throw;
}
}
public static string VKIHesaplama(int kilo,int boy)
{
float vki = kilo/boy*boy;
if (vki>18.5 && vki < 30.0)
return vki >18.5 && vki <24.9 ? "Healthy weight " : "Over weight";
else if (vki>30)
return " obesity";
else return "underweight";
}
}
}
o ne demekLan direkt yazakmı
kanka en son attıgıma bak onda cıkmıyoraga
githubdakini bulamadım buaraya atsana
Mesaj otomatik birleştirildi:
bi de hep obez çıkıyo
Do you want to continue yerine Do you want to try again? olabilirusing System;
namespace BMI
{
internal class Program
{
static void Main(string[] args)
{
int age, weight = 0;
float size = 0;
Boolean contunie = true;
int contunie2 = 1;
Console.WriteLine("Please enter the age:");
age = Convert.ToInt32(Console.ReadLine());
try
{
do
{
if (age >= 20)
{
Console.WriteLine("please enter your weight:");
weight = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please enter the size");
size= Convert.ToInt32(Console.ReadLine());
Console.WriteLine(VKIHesaplama(weight, size));
Console.WriteLine("Do you want to continue? 1)) YES 2)) NO");
contunie2 = Convert.ToInt32(Console.ReadLine());
switch (contunie2)
{
case 1: contunie = true; break;
case 2: contunie= false; break;
}
}
else
Console.WriteLine("Age must be 20 and over, please enter again");
} while (contunie);
}
catch (FormatException error)
{
Console.WriteLine("WRONG FORMAT PLEASE TRY AGAIN!!!");
}
catch (Exception)
{
throw;
}
}
public static string VKIHesaplama(int weight, float size)
{
float boyvki = size/ 100;
Console.WriteLine(boyvki);
float vki = size / boyvki * boyvki;
if (vki > 18.5 && vki < 30.0)
return vki > 18.5 && vki < 24.9 ? "Healthy weight " : "Over weight";
else if (vki > 30)
return " obesity";
else return "underweight";
}
}
}
şöyle değiştrdim ing olarak yanlıs varmı?
bu yanlış kanka eskisiusing System; namespace MyApp { internal class Program { static void Main(string[] args) { int yas, kilo=0, boy=0; Boolean devam = true; int devam2 = 1; Console.WriteLine("please enter your age"); yas =Convert.ToInt32(Console.ReadLine()); Console.WriteLine(yas); try { do { if (yas >= 20) { Console.WriteLine("Lütfen kilo giriniz"); kilo =Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Lütfen boy giriniz"); boy =Convert.ToInt32(Console.ReadLine()); Console.WriteLine(VKIHesaplama(kilo, boy)); Console.WriteLine("Devam etmek istiyor musunuz? 1-Evet 2-Hayır"); devam2 =Convert.ToInt32(Console.ReadLine()); switch (devam2) { case 1:devam = true; break; case 2:devam = false; break; } } else Console.WriteLine("Yas 20 ve üstü olmalıdır tekrar giriniz."); } while (devam); } catch (FormatException hata) { Console.WriteLine("Yanlış formatta değer girildi tekrar giriniz."); } catch (Exception) { throw; } } public static string VKIHesaplama(int kilo,int boy) { float vki = kilo/boy*boy; if (vki>18.5 && vki < 30.0) return vki >18.5 && vki <24.9 ? "Healthy weight " : "Over weight"; else if (vki>30) return " obesity"; else return "underweight"; } } }