Methodslar neler arkadaslar?
Methods C#
Cevaplar
Yapılan uygulama içerisinde bölümlere, kendi içerisinde küçük parçalara ayrılarak oluşturulan ve sonradan çağırılma amacı ile kullanılabilen kod satırlarıdır.
stirng name falan vardı
for döngüsü falan var onlar mı?
using System;
namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
int day = 4;
switch (day)
{
case 1:
Console.WriteLine("Monday");
break;
case 2:
Console.WriteLine("Tuesday");
break;
case 3:
Console.WriteLine("Wednesday");
break;
case 4:
Console.WriteLine("Thursday");
break;
case 5:
Console.WriteLine("Friday");
break;
case 6:
Console.WriteLine("Saturday");
break;
case 7:
Console.WriteLine("Sunday");
break;
}
}
}
}
c# iyi dildir
namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
int day = 4;
switch (day)
{
case 1:
Console.WriteLine("Monday");
break;
case 2:
Console.WriteLine("Tuesday");
break;
case 3:
Console.WriteLine("Wednesday");
break;
case 4:
Console.WriteLine("Thursday");
break;
case 5:
Console.WriteLine("Friday");
break;
case 6:
Console.WriteLine("Saturday");
break;
case 7:
Console.WriteLine("Sunday");
break;
}
}
}
}
c# iyi dildir
düzenlendi
harika bir dildir
Yapılan uygulama içerisin
Çok doğruNecimDurmaz dedi: ↑harika bir dildir
Bu dille alakalı bazı sorularım var ama
ilk sorum bu;
namespace ExamStudyy2
{
//method kullanarak hesap makinesi yapma
internal class Program
{
public static int result = 0;
public static void hesapMakinesi()
{
Console.WriteLine("Enter the number one: ");
int sayi1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the number two: ");
int sayi2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the op: +,-,*,/");
string op = Console.ReadLine();
switch (op)
{
case "+":
result = sayi1 + sayi2;
break;
case "-":
result = sayi1 - sayi2;
break;
case "*":
result = sayi1 * sayi2;
break;
case "/":
result = sayi1 / sayi2;
break;
default:
Console.Write("Enter a valid op");
break;
}
}
static void Main(string[] args)
{
hesapMakinesi();
Console.WriteLine("The result is: " + result);
Console.Read();
}
}
}
ikinci sorum şu;
namespace examStudyHighScore
{
internal class Program
{
static int highScore = 150;
static string highScorePlayer = "Ethan";
static void highScoreApp()
{
Console.WriteLine("Enter your name and score: ");
string name = Console.ReadLine();
int score = Int32.Parse(Console.ReadLine());
if (score > highScore)
{
score = highScore;
highScorePlayer = name;
Console.WriteLine("Now you have the highest score " + name + "!");
}
else
{
Console.WriteLine(highScore + "is the highest score. Owner is " + highScorePlayer);
}
}
static void Main(string[] args)
{
highScoreApp();
Console.Read();
}
}
}
üçüncü sorum şu;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace examStudyTryCatch
{
internal class Program
{
//Hata yakalamak için try catch kullandık. Catch kısmında hatanın sonucunda
// ne olacağına karar verdik.
static void Main(string[] args)
{
//try
//{
// Console.WriteLine("Enter a number: ");
// var num = Int32.Parse(Console.ReadLine());
// if (num <= 15)
// {
// Console.WriteLine("It's too cold");
// }
// else if (num <= 16 && num <= 28)
// {
// Console.WriteLine("It's okay");
// }
// else
// {
// Console.WriteLine("It's too hot.");
// }
//}
//catch (Exception ex)
//{
// Console.Write("Error info:" + ex.Message);
//}
Console.Write("Please enter a number to divide 100: ");
try
{
int num = int.Parse(Console.ReadLine());
int result = 100 / num;
Console.WriteLine("100 / {0} = {1}", num, result);
}
catch (DivideByZeroException ex)
{
Console.Write("Cannot divide by zero. Please try again.");
}
catch (InvalidOperationException ex)
{
Console.Write("Invalid operation. Please try again.");
}
catch (FormatException ex)
{
Console.Write("Not a valid format. Please try again.");
}
catch (Exception ex)
{
Console.Write("Error occurred! Please try again.");
}
Console.ReadKey();
}
}
}
dördüncü sorum şu;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace examStudyy
{
internal class Program
{
//static void MyMethod()
//{
// Console.WriteLine("My method example");
//}
static void methodString(string ad, string soyAd)
{
Console.WriteLine(ad + soyAd);
}
static void countries(string country = "Turkey")
{
Console.WriteLine(country);
}
static int numberX(int x)
{
return 5 + x;
}
static int numberXandY(int x, int y)
{
return x + y;
}
static int anotherXandY(int x, int y)
{
return x + y;
}
static void childNames(string child1, string child2, string child3)
{
Console.WriteLine("The youngest child is: " + child3);
}
static void Main(string[] args)
{
methodString("Selahattin ", "Acar");
methodString("Onat ", "Aydın");
methodString("Erdem ", "Akdoğan");
countries("Iceland");
countries("Germany");
countries();
countries("USA");
Console.WriteLine(numberX(2));
Console.WriteLine(numberX(3));
Console.WriteLine(numberX(4));
Console.WriteLine(numberXandY(5, 8));
Console.WriteLine(numberXandY(10, 21));
Console.WriteLine(numberXandY(15, 300));
int z = anotherXandY(3, 5);
Console.WriteLine(z);
int b = anotherXandY(6, 7);
Console.WriteLine(b);
childNames(child3: "Ethan", child2: "Karen", child1: "Amber");
//MyMethod();
Console.ReadLine();
}
}
}
BURADA HATALARIMI NASIL BULACAĞIM?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace examDenemee
{
class Program
{
static void Main(string[] args)
{
string input = "0";
int count = 0;
int total = 0;
int currentNumber = 0;
while (input != "-1")
{
Console.WriteLine("Last number was {0}", currentNumber);
Console.WriteLine("Please enter the next score");
Console.WriteLine("Current amount of entries {0}", count);
Console.WriteLine("Please enter -1 once you are ready to calculate the average");
input = Console.ReadLine();
if (input == ("-1"))
{
Console.WriteLine("--------------------------------------------");
double average = (double)total / (double)count;
Console.WriteLine("The average score of your students is {0}", average);
}
if (int.TryParse(input, out currentNumber) && currentNumber > 0 && currentNumber < 21)
{
total += currentNumber;
}
else
{
if (!(input.Equals("-1")))
{
Console.WriteLine("Please enter a value between 1 and 20!");
}
continue;
}
count++;
}
Console.ReadLine();
}
}
}
BU KONULARDA ZORLANIYORUM
https://drive.google.com/drive/folders/14VWLFrBHp_eURirgbhuruU1l14muzZDT
ilk sorum bu;
namespace ExamStudyy2
{
//method kullanarak hesap makinesi yapma
internal class Program
{
public static int result = 0;
public static void hesapMakinesi()
{
Console.WriteLine("Enter the number one: ");
int sayi1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the number two: ");
int sayi2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the op: +,-,*,/");
string op = Console.ReadLine();
switch (op)
{
case "+":
result = sayi1 + sayi2;
break;
case "-":
result = sayi1 - sayi2;
break;
case "*":
result = sayi1 * sayi2;
break;
case "/":
result = sayi1 / sayi2;
break;
default:
Console.Write("Enter a valid op");
break;
}
}
static void Main(string[] args)
{
hesapMakinesi();
Console.WriteLine("The result is: " + result);
Console.Read();
}
}
}
ikinci sorum şu;
namespace examStudyHighScore
{
internal class Program
{
static int highScore = 150;
static string highScorePlayer = "Ethan";
static void highScoreApp()
{
Console.WriteLine("Enter your name and score: ");
string name = Console.ReadLine();
int score = Int32.Parse(Console.ReadLine());
if (score > highScore)
{
score = highScore;
highScorePlayer = name;
Console.WriteLine("Now you have the highest score " + name + "!");
}
else
{
Console.WriteLine(highScore + "is the highest score. Owner is " + highScorePlayer);
}
}
static void Main(string[] args)
{
highScoreApp();
Console.Read();
}
}
}
üçüncü sorum şu;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace examStudyTryCatch
{
internal class Program
{
//Hata yakalamak için try catch kullandık. Catch kısmında hatanın sonucunda
// ne olacağına karar verdik.
static void Main(string[] args)
{
//try
//{
// Console.WriteLine("Enter a number: ");
// var num = Int32.Parse(Console.ReadLine());
// if (num <= 15)
// {
// Console.WriteLine("It's too cold");
// }
// else if (num <= 16 && num <= 28)
// {
// Console.WriteLine("It's okay");
// }
// else
// {
// Console.WriteLine("It's too hot.");
// }
//}
//catch (Exception ex)
//{
// Console.Write("Error info:" + ex.Message);
//}
Console.Write("Please enter a number to divide 100: ");
try
{
int num = int.Parse(Console.ReadLine());
int result = 100 / num;
Console.WriteLine("100 / {0} = {1}", num, result);
}
catch (DivideByZeroException ex)
{
Console.Write("Cannot divide by zero. Please try again.");
}
catch (InvalidOperationException ex)
{
Console.Write("Invalid operation. Please try again.");
}
catch (FormatException ex)
{
Console.Write("Not a valid format. Please try again.");
}
catch (Exception ex)
{
Console.Write("Error occurred! Please try again.");
}
Console.ReadKey();
}
}
}
dördüncü sorum şu;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace examStudyy
{
internal class Program
{
//static void MyMethod()
//{
// Console.WriteLine("My method example");
//}
static void methodString(string ad, string soyAd)
{
Console.WriteLine(ad + soyAd);
}
static void countries(string country = "Turkey")
{
Console.WriteLine(country);
}
static int numberX(int x)
{
return 5 + x;
}
static int numberXandY(int x, int y)
{
return x + y;
}
static int anotherXandY(int x, int y)
{
return x + y;
}
static void childNames(string child1, string child2, string child3)
{
Console.WriteLine("The youngest child is: " + child3);
}
static void Main(string[] args)
{
methodString("Selahattin ", "Acar");
methodString("Onat ", "Aydın");
methodString("Erdem ", "Akdoğan");
countries("Iceland");
countries("Germany");
countries();
countries("USA");
Console.WriteLine(numberX(2));
Console.WriteLine(numberX(3));
Console.WriteLine(numberX(4));
Console.WriteLine(numberXandY(5, 8));
Console.WriteLine(numberXandY(10, 21));
Console.WriteLine(numberXandY(15, 300));
int z = anotherXandY(3, 5);
Console.WriteLine(z);
int b = anotherXandY(6, 7);
Console.WriteLine(b);
childNames(child3: "Ethan", child2: "Karen", child1: "Amber");
//MyMethod();
Console.ReadLine();
}
}
}
BURADA HATALARIMI NASIL BULACAĞIM?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace examDenemee
{
class Program
{
static void Main(string[] args)
{
string input = "0";
int count = 0;
int total = 0;
int currentNumber = 0;
while (input != "-1")
{
Console.WriteLine("Last number was {0}", currentNumber);
Console.WriteLine("Please enter the next score");
Console.WriteLine("Current amount of entries {0}", count);
Console.WriteLine("Please enter -1 once you are ready to calculate the average");
input = Console.ReadLine();
if (input == ("-1"))
{
Console.WriteLine("--------------------------------------------");
double average = (double)total / (double)count;
Console.WriteLine("The average score of your students is {0}", average);
}
if (int.TryParse(input, out currentNumber) && currentNumber > 0 && currentNumber < 21)
{
total += currentNumber;
}
else
{
if (!(input.Equals("-1")))
{
Console.WriteLine("Please enter a value between 1 and 20!");
}
continue;
}
count++;
}
Console.ReadLine();
}
}
}
BU KONULARDA ZORLANIYORUM
https://drive.google.com/drive/folders/14VWLFrBHp_eURirgbhuruU1l14muzZDT
düzenlendi
teşekkürler.
Cihaz.
using System;
namespace MyApp // Note: actual 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";
}
}
}
using System;
namespace MyApp // Note: actual 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";
}
}
}
düzenlendi
using System;
namespace MyApp // Note: actual namespace depends on the project name.
{
internal class Program
{
static void Main(string[] args)
{
int yas, kilo = 0;
float boy=0;
Boolean devam = true;
int devam2 = 1;
Console.WriteLine("Lütfen yasinizi giriniz");
yas =Convert.ToInt32(Console.ReadLine());
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,float boy)
{
float boyvki=boy/100 ;
Console.WriteLine(boyvki);
float vki = kilo/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";
}
}
}
namespace MyApp // Note: actual namespace depends on the project name.
{
internal class Program
{
static void Main(string[] args)
{
int yas, kilo = 0;
float boy=0;
Boolean devam = true;
int devam2 = 1;
Console.WriteLine("Lütfen yasinizi giriniz");
yas =Convert.ToInt32(Console.ReadLine());
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,float boy)
{
float boyvki=boy/100 ;
Console.WriteLine(boyvki);
float vki = kilo/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";
}
}
}
boy'da cm yerine metre kullanılıyormuş bir bakmanı öneririm :)Cihaz.
using System;
namespace MyApp // Note: actual 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";
}
}
}
düzenlendi
Lan direkt yazakmı
nasıl uygukuoyruz
düzenlendi
aga obesite cıkıyo hep neden
son halini al kanka son halinde düzgün cıkıyor ılk hlaınde dönüşüm yapmamıştım
tamam hallettım
using System;
namespace MyApp // Note: actual namespace depends on the project name.
{
internal class Program
{
static void Main(string[] args)
{
int yas, kilo = 0;
float boy = 0;
Boolean devam = true;
int devam2 = 1;
Console.WriteLine("Lütfen yasinizi giriniz");
yas =Convert.ToInt32(Console.ReadLine());
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, float boy)
{
float boyvki = boy/100;
float vki = kilo/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";
}
}
}
try parse ile de yaptım githubtan bakın hangisini istiyosanız ikisi de doğru karışık yapın işte
namespace MyApp // Note: actual namespace depends on the project name.
{
internal class Program
{
static void Main(string[] args)
{
int yas, kilo = 0;
float boy = 0;
Boolean devam = true;
int devam2 = 1;
Console.WriteLine("Lütfen yasinizi giriniz");
yas =Convert.ToInt32(Console.ReadLine());
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, float boy)
{
float boyvki = boy/100;
float vki = kilo/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";
}
}
}
try parse ile de yaptım githubtan bakın hangisini istiyosanız ikisi de doğru karışık yapın işte
aga
githubdakini bulamadım buaraya atsana
bi de hep obez çıkıyo
githubdakini bulamadım buaraya atsana
bi de hep obez çıkıyo
using 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ı?
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ı?
kanka en son attıgıma bak onda cıkmıyoraga
githubdakini bulamadım buaraya atsana
bi de hep obez çıkıyo
buraya da attım
using 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"; } } }
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ı?
devam etmiyor tekrardan baştan başlıyor diye ama siz bilirsiniz
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"; } } }
using System;
namespace MyApp // Note: actual namespace depends on the project name.
{
internal class Program
{
static void Main(string[] args)
{
int yas, kilo = 0;
float boy=0;
Boolean devam = true;
int devam2 = 1;
Console.WriteLine("Lütfen yasinizi giriniz");
yas =Convert.ToInt32(Console.ReadLine());
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,float boy)
{
float boyvki=boy/100 ;
float vki = kilo/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";
}
}
}
tamamdır halloldu
başka takılan ve ya takıldığınız bir yer var mı
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bmihesaplama
{
internal class Program
{
static void Main(string[] args)
{
int yas, kilo = 0;
float boy = 0;
Boolean ilerle = true;
int ilerle2 = 1;
Console.WriteLine("Lütfen yasinizi giriniz");
yas = Convert.ToInt32(Console.ReadLine());
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");
ilerle2 = Convert.ToInt32(Console.ReadLine());
switch (ilerle2)
{
case 1: ilerle = true; break;
case 2: ilerle = false; break;
}
}
else
Console.WriteLine("Yas 20 ve üstü olmalıdır tekrar giriniz.");
} while (ilerle);
}
catch (FormatException hata)
{
Console.WriteLine("Yanlış formatta değer girildi tekrar giriniz.");
}
catch (Exception)
{
throw;
}
}
public static string VKIHesaplama(int kilo, float boy)
{
float boyvki = boy / 100;
float vki = kilo / (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";
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bmihesaplama
{
internal class Program
{
static void Main(string[] args)
{
int yas, kilo = 0;
float boy = 0;
Boolean ilerle = true;
int ilerle2 = 1;
Console.WriteLine("Lütfen yasinizi giriniz");
yas = Convert.ToInt32(Console.ReadLine());
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");
ilerle2 = Convert.ToInt32(Console.ReadLine());
switch (ilerle2)
{
case 1: ilerle = true; break;
case 2: ilerle = false; break;
}
}
else
Console.WriteLine("Yas 20 ve üstü olmalıdır tekrar giriniz.");
} while (ilerle);
}
catch (FormatException hata)
{
Console.WriteLine("Yanlış formatta değer girildi tekrar giriniz.");
}
catch (Exception)
{
throw;
}
}
public static string VKIHesaplama(int kilo, float boy)
{
float boyvki = boy / 100;
float vki = kilo / (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";
}
}
}