i have a serious problem in C# console application, the following code doesn't work as what i want... it must ask me to type the following letters value, then it must calculate with the values i typed, but when i type a character such as 'x', it doesn't make it equivalent to "1", how can i solve that problem???, what is the certain solution?? "x" value should be equivalent to 1
string nun = "2";
Console.WriteLine("Type the 'A' value");
double a = Convert.ToInt32(Console.ReadLine());
if (a=='x') {
a = 1
}
Console.WriteLine("Type the 'B' value");
double b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Type the 'C' value");
double c = Convert.ToInt32(Console.ReadLine());
double delta = Math.Pow(b,2) - (4*a*c);
if(delta > 0 ) {
double x1 = (-b + Math.Sqrt(delta) / 2 * a);
Console.WriteLine("value of x1: {0}",Convert.ToInt32(x1));
double x2 = (-b - Math.Sqrt(delta) / 2 * a);
Console.WriteLine("value of x2: {0}",Convert.ToInt32(x2));
}
else if (delta < 0) {
Console.WriteLine("there is no any different real root in this equation!");
}
1instead ofx? Your code shows that you want to allow user to enternumbernot any non-numeric string.x.double a = Convert.ToInt32(Console.ReadLine()); if (a=='x')