KonsCalc

Basit bir C# konsol uygulaması hesap makinesi yani çok da bir esprisi yok
Its just a simple C# console app a calculator so there s not much to it
C# ı ilk öğrenirken yapmıştım bu uygulamayı hocama sormuştum hocam projede [] köşeli parantezler ne işe yarıyor diye hoca süs için demişti ben bi türlü anlamayıp hocayı darlamıştım baya hoca en sonunda bıktı benden meğersem dizilerde kullanılan parantezle karıştırıyor muşum lol :>
I made this application when I was first learning C# and asked my teacher what the square brackets [ ] were for in the project He said they were just for show but I couldnt get it and kept bugging him about it In the end he got fed up with me and it turns out I was confusing them with the brackets used for arrays lol :>
using static System.Net.Mime.MediaTypeNames;
using System.Collections.Generic;
int sayi1, sayi2, sonuc, islem;
string dil;
Console.WriteLine("TR/ENG");
Console.Write("Please choose a language: ");
dil = Console.ReadLine();
//burada dil seçiyoruz Console.ReadLine komudu konsola girdiğimiz değeri okuyup dil e atması için
//Here we choose the language; the Console.ReadLine command reads the value we enter in the console and assigns it to the variable dil
if (dil == "TR")
{
Console.Clear();
Console.WriteLine("Hesap Makinesine hoşgeldiniz");
Console.WriteLine("Toplama işlemi[1]");
Console.WriteLine("Çıkarma İşlemi[2]");
Console.WriteLine("Çarpma İşlemi[3]");
Console.WriteLine("Bölme İşlemi[4]");
//burdaki köşeli parantezler sadece süs için ha
Console.Write("Yapmak istediğiniz işlemi seçin: ");
islem = Convert.ToInt32(Console.ReadLine());
//Burada yapmak istediğimiz işlemi seçiyoruz convert.toInt ifadedesi konsola girmiğimiz değeri int e çeviriyor Console readline konsola bir değer girdiğimizde onu okuması için
if(islem == 1)
{
Console.Clear();
Console.WriteLine("Toplama İşlemini seçtiniz");
Console.Write("1. sayıyı giriniz: ");
sayi1 = Convert.ToInt32(Console.ReadLine());
Console.Write("2. sayıyı giriniz: ");
sayi2 = Convert.ToInt32(Console.ReadLine());
sonuc = sayi1 + sayi2;
Console.Clear() ;
Console.WriteLine("Yaptığınız işlemin sonucu={0}", sonuc);
//Buradaki "{0}" virgülden sonra yazdığımız değişkenin değerini yazdırıyor tabi ki bu 1, 2, 3, 4 gibi devam edebilir
//Geri kalan kodlar buradakilerle hemen hemen aynı sadece isimle ile işlem başka
}
if (islem == 2)
{
Console.Clear();
Console.WriteLine("Çıkarma İşlemini seçtiniz");
Console.Write("1. sayıyı giriniz: ");
sayi1 = Convert.ToInt32(Console.ReadLine());
Console.Write("2. sayıyı giriniz: ");
sayi2 = Convert.ToInt32(Console.ReadLine());
sonuc = sayi1 - sayi2;
Console.Clear();
Console.WriteLine("Yaptığınız işlemin sonucu={0}", sonuc);
}
if (islem == 3)
{
Console.Clear();
Console.WriteLine("Çarpma İşlemini seçtiniz");
Console.Write("1. sayıyı giriniz: ");
sayi1 = Convert.ToInt32(Console.ReadLine());
Console.Write("2. sayıyı giriniz: ");
sayi2 = Convert.ToInt32(Console.ReadLine());
sonuc = sayi1 * sayi2;
Console.Clear();
Console.WriteLine("Yaptığınız işlemin sonucu={0}", sonuc);
}
if (islem == 4)
{
Console.Clear();
Console.WriteLine("Bölme İşlemini seçtiniz");
Console.Write("1. sayıyı giriniz: ");
sayi1 = Convert.ToInt32(Console.ReadLine());
Console.Write("2. sayıyı giriniz: ");
sayi2 = Convert.ToInt32(Console.ReadLine());
sonuc = sayi1 / sayi2;
Console.Clear();
Console.WriteLine("Yaptığınız işlemin sonucu={0}", sonuc);
}
}
if (dil == "ENG")
{
Console.Clear();
Console.WriteLine("Welcome to the calculator");
Console.WriteLine("Addition operation[1]");
Console.WriteLine("Subtraction operation[2]");
Console.WriteLine("Multiplication operation[3]");
Console.WriteLine("Division operation[4]");
//The square brackets here are just for show, huh?
Console.Write("Pick the operation you wanna do: ");
islem = Convert.ToInt32(Console.ReadLine());
//Here, we choose the operation we want to perform; the Convert.ToInt statement converts the value we input into the console to an int, while Console.ReadLine reads the value we enter
if (islem == 1)
{
Console.Clear();
Console.WriteLine("You chose the addition operation");
Console.Write("Enter the first digit: ");
sayi1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter the second digit: ");
sayi2 = Convert.ToInt32(Console.ReadLine());
sonuc = sayi1 + sayi2;
Console.Clear();
Console.WriteLine("The result of the operation you did={0}", sonuc);
//Here, '{0}' prints the value of the variable we wrote after the comma; of course, it can continue with 1, 2, 3, 4, and so on
//The rest of the code is basically the same, just the names and the operations switch up.
}
if (islem == 2)
{
Console.Clear();
Console.WriteLine("You chose the subtraction operation");
Console.Write("Enter the first digit: ");
sayi1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter the second digit: ");
sayi2 = Convert.ToInt32(Console.ReadLine());
sonuc = sayi1 - sayi2;
Console.Clear();
Console.WriteLine("The result of the operation you did={0}", sonuc);
}
if (islem == 3)
{
Console.Clear();
Console.WriteLine("You chose the multiplication operation");
Console.Write("Enter the first digit: ");
sayi1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter the second digit: ");
sayi2 = Convert.ToInt32(Console.ReadLine());
sonuc = sayi1 * sayi2;
Console.Clear();
Console.WriteLine("The result of the operation you did={0}", sonuc);
}
if (islem == 4)
{
Console.Clear();
Console.WriteLine("You chose the division operation");
Console.Write("Enter the first digit: ");
sayi1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter the second digit: ");
sayi2 = Convert.ToInt32(Console.ReadLine());
sonuc = sayi1 / sayi2;
Console.Clear();
Console.WriteLine("The result of the operation you did={0}", sonuc);
}
}
Subscribe to my newsletter
Read articles from Yasir Yurduseven directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Yasir Yurduseven
Yasir Yurduseven
meslek lisesinde bilişim okuyorum okulda veya çevreden öğrendiklerimi burada paylaşmak istiyorum fikirlerinizi belirtirseniz aşırı mutlu olurum I am studying IT at a vocational high school, and I want to share what I learn at school or from my surroundings here. I would be extremely happy if you share your thoughts. I want to become an electrical and electronics engineer in the future, or a software developer.