Witam,
stworzyłem program w visual basicu do obliczania całek metoda trapezów, prostokątów i parabol. Jak dodać kod w programie abym w comboboxie mógł wyswietlac która metoda chce aby program liczył.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double f (double x)
{
return Math.Pow(x, 2) - 2 * x + 3;
}
private void button1_Click(object sender, EventArgs e)
{
double a = Convert.ToDouble(textBoxA.Text);
double b = Convert.ToDouble(textBoxB.Text);
double N = Convert.ToDouble(textBoxN.Text);
double xi,
Pi,
wartosc_calki = 0;
double h = (b - a) / N;
for (int i = 0; i < N; i++)
{
xi = a + h + i;
Pi = h * f(xi);
//Pi = h * f(xi + h / 2); //met.prost. wz. otw
//Pi = h / 2 * (f(xi) + f(xi + h)); //met. trap. wz. zamk.
// Pi = h / 2 * (f(xi + h / 3) + f(xi + 2 * h / 3)); //met. trap wz otw
//Pi = h / 6 * (f(xi) + 4 * f(xi + h / 2) + f(xi + h));//met. parabol zamk.
wartosc_calki += Pi;
}
textBoxWynik.Text = wartosc_calki.ToString();
}
}
}