Опитвам се да направя проста конзолна програма, която може да решава квадратни уравнения. Все още не съм разбрал как да изчисля отговорите, ако дискриминантът е отрицателно число, така че просто показах съобщение като заместител. Може ли някой да обясни как се прави това? Ще публикувам цялата програма за всякакви предложения. Благодаря.
Правилно работещ код (Благодаря, Гюнтер Фокс):
if(discriminant < 0)
{
double x1 = -b/(2*a);
discriminant = -discriminant ;
double x2 = Math.Sqrt(discriminant)/(2*a);
double x3 = -Math.Sqrt(discriminant)/(2*a);
Console.WriteLine(x1.ToString() + " + " + x2.ToString() + " * i ");
Console.WriteLine(x1.ToString() + " + " + x3.ToString() + " * i ");
Console.ReadLine();
}
Стар код:
class Program
{
static void Main(string[] args)
{
int choice;
double ans1;
double ans2;
Console.WriteLine("~~~~~~~~ TERMINAL CALCULATOR ~~~~~~~~");
Console.WriteLine("1. Standard Calculator\n2. Quadratic Equation Solver\n3. Simple Interest Calculator");
choice = int.Parse(Console.ReadLine());
try
{
if (choice == 2)
{
Console.Write("Enter a value for 'a': ");
double a = double.Parse(Console.ReadLine());
Console.Write("Enter a value for 'b': ");
double b = double.Parse(Console.ReadLine());
Console.Write("Enter a value for 'c': ");
double c = double.Parse(Console.ReadLine());
//Quadratic Formula: x = (-b +- sqrt(b^2 - 4ac)) / 2a
//Solve disriminant: (b*b) - (4*a*c)
double discriminant = (b * b) - (4 * a * c);
if (discriminant < 0)
{
Console.WriteLine("No real solutions");
Console.ReadLine();
}
else
{
double sqrt = Math.Sqrt(discriminant);
ans1 = (-b + sqrt) / (2 * a);
ans2 = (-b - sqrt) / (2 * a);
Console.WriteLine("{" + ans1 + " , " + ans2 + "}");
Console.ReadLine();
}
}
if (choice == 1)
{
Console.Write("Enter first number: ");
double num1 = double.Parse(Console.ReadLine());
Console.Write("Enter second number (Enter 0 if you want to use sqrt): ");
double num2 = double.Parse(Console.ReadLine());
//Prompt user to choose an operation
Console.WriteLine("Choose a math operator:\n1. +\n2. -\n3. x\n4. /\n5. ^\n6. Square root");
int mathOpr = int.Parse(Console.ReadLine());
if (mathOpr == 1)
{
double answer = num1 + num2;
Console.WriteLine("\n\n" + answer);
Console.ReadLine();
}
if (mathOpr == 2)
{
double answer = num1 - num2;
Console.WriteLine("\n\n" + answer);
Console.ReadLine();
}
if (mathOpr == 3)
{
double answer = num1 * num2;
Console.WriteLine("\n\n" + answer);
Console.ReadLine();
}
if (mathOpr == 4)
{
double answer = num1 / num2;
Console.WriteLine("\n\n" + answer);
Console.ReadLine();
}
if (mathOpr == 5)
{
double answer = Math.Pow(num1, num2);
Console.WriteLine("\n\n" + answer);
Console.ReadLine();
}
if (mathOpr == 6)
{
if (num1 < 0)
{
Console.WriteLine("\n\nNo real solutions");
}
else
{
double answer = Math.Sqrt(num1);
Console.WriteLine("\n\n" + answer);
}
}
else
{
Console.WriteLine("That is not a valid option, idiot.");
Console.ReadLine();
}
}
if (choice == 3)
{
Console.WriteLine("Enter initial amount: ");
double initAmount = double.Parse(Console.ReadLine());
Console.WriteLine("Enter interest rate (ex. 6% = .06): ");
double rate = double.Parse(Console.ReadLine());
Console.WriteLine("Enter time range (Year, Month, Week, etc.): ");
string timeRange = Console.ReadLine();
Console.WriteLine("Enter amount of " + timeRange.ToLower() + "s: ");
int time = int.Parse(Console.ReadLine());
for (int time2 = 1; time2 <= time; time2++)
{
double totalAmount = initAmount * Math.Pow(1 + rate, time2);
Console.WriteLine("\n" + timeRange + " " + time2 + " ---------- " + totalAmount);
}
Console.ReadLine();
}
}
catch
{
Console.WriteLine("That is not a valid option.");
}
}
}
Възможно ли е да деактивирате или изтриете cron задание от базата данни на magento.
- person phant0m   schedule 20.12.2012Добавих cron задание и случайно добавих *, което изпълнява cron заданието на всеки секунди и функцията добавя данни в базата данни.
Поради което моят ftp достъп е спрял.
Искам да го деактивирам/изтрия от phpmyadmin.
Моля, помогнете