private static void Proje()
{
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.Write("Labaratuvar hesaplaycı için 1'i,\nbireysel hesaplayıcı için 2'yi\nProgramı kapatmak için 3'ü tuşlayın.\n\nHangisini tercih ederdiniz: ");
while (true)
{
var input = Console.ReadKey().Key;
if (input is ConsoleKey.D1 or ConsoleKey.NumPad1)
{
LabCalculator();
break;
}
else if (input is ConsoleKey.D2 or ConsoleKey.NumPad2)
{
PersonalCalculator();
break;
}
else if (input is ConsoleKey.D3 or ConsoleKey.NumPad3)
{
Console.ResetColor();
Console.Write("\nProgram kapatılıyor.");
Thread.Sleep(321);
Console.Write(".");
Thread.Sleep(321);
Console.Write(".");
Thread.Sleep(321);
Environment.Exit(0);
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\nGeçersiz giriş, lütfen tekrar deneyin.\n");
}
}
}
private static void LabCalculator()
{
Console.Clear();
Console.Write("|--- Lab Calculator ---|\nToplama için 1'i,\nÇarpım için 2'yi,\nAritmetik Ortalama için 3'ü,\nİkinci dereceden denklemler için 4'ü," +
"\nn'inci dereceden polinom için 5'i,\nNewton sembolü hesaplama için 6'yı,\nOnluk -> İkili dönüşümü için 7'yi,\nGeri dönmek için 8'i,\nÇıkmak için 9'u tuşlayın.\n\nHangisini tercih ederdiniz: ");
bool cond = true;
while (cond)
{
var key = Console.ReadKey().Key;
cond = false;
Console.WriteLine("\n");
switch (key)
{
case ConsoleKey.D1 or ConsoleKey.NumPad1:
Addition();
break;
case ConsoleKey.D2 or ConsoleKey.NumPad2:
break;
case ConsoleKey.D3 or ConsoleKey.NumPad3:
break;
case ConsoleKey.D4 or ConsoleKey.NumPad4:
break;
case ConsoleKey.D5 or ConsoleKey.NumPad5:
break;
case ConsoleKey.D6 or ConsoleKey.NumPad6:
break;
case ConsoleKey.D7 or ConsoleKey.NumPad7:
break;
case ConsoleKey.D8 or ConsoleKey.NumPad8:
Console.Clear();
Proje();
break;
case ConsoleKey.D9 or ConsoleKey.NumPad9:
EnviromentExit();
break;
default:
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\nGeçersiz giriş, lütfen tekrar deneyin.\n");
break;
}
}
}
private static void Addition()
{
double total = 0;
while (true)
{
try
{
Console.ResetColor();
Console.Write("Sayıları yazın (Örn: 1+2+3+4+5): ");
var trim = Console.ReadLine()!.Split('+');
for (int i = 0; i < trim.Length; i++)
total += Convert.ToDouble(trim[i]);
Console.ForegroundColor = ConsoleColor.Green;
Console.Write($"\n\nToplam sonuç: {total}");
Console.ResetColor();
break;
}
catch
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\nHatalı giriş yaptınız. Tekrar deneyin.");
}
}
}
private static void Multiplication(double[] numbers)
{
double total = 0;
foreach (var item in numbers)
total *= item;
Console.WriteLine($"\nSonuç: {total}\n");
}
private static void ArithmeticMean(double[] numbers)
{
double sum = 0;
foreach (var number in numbers)
sum += number;
double mean = sum / numbers.Length;
Console.WriteLine($"\nSonuç: Aritmetik Ortalama = {mean}\n");
}
private static void QuadraticEquation(double a, double b, double c)
{
double discriminant = b * b - 4 * a * c;
if (discriminant > 0)
{
double root1 = (-b + Math.Sqrt(discriminant)) / (2 * a);
double root2 = (-b - Math.Sqrt(discriminant)) / (2 * a);
Console.WriteLine($"\nSonuç: İki gerçek kök var: x1 = {root1}, x2 = {root2}\n");
}
else if (discriminant == 0)
{
double root = -b / (2 * a);
Console.WriteLine($"\nSonuç: Çift katlı kök var: x = {root}\n");
}
else
Console.WriteLine("\nSonuç: Gerçek kök yok.\n");
}
private static void PersonalCalculator()
{
// Blabla...
}