I have a txtBox and a button to calculate the area under the function I want to know how to take the txt and make it a function like this "-x * x * x + 10 * x * x + 8 * x + 10;"
private void button1_Click(object sender, EventArgs e)
{
string pivote;
pivote = txtEcuacion1.Text;
double ecuacion;
double base_rectangulo, altura_1, altura_2, altura_total, x;
double partes = 8, area = 0;
double lim_inferior = 3, lim_superior = 7;
base_rectangulo = (lim_superior - lim_inferior) / partes;
x = lim_inferior;
while (x < lim_superior)
{
altura_1 = Convert.ToDouble(pivote);//-x * x * x + 10 * x * x + 8 * x + 10;
x = x + base_rectangulo;
altura_2 = Convert.ToDouble(pivote); //-x * x * x + 10 * x * x + 8 * x + 10;
altura_total = (altura_1 + altura_2) / 2;
area = area + base_rectangulo * altura_total;
}
MessageBox.Show("El valor del area es" + area);
}
In "altura_1" I tried to convert it to double but it didn't work