rendered paste bodyusing System;
using System.Collections.Generic;
using System.Text;
namespace gauss
{
class Program
{
static void Main(string[] args)
{
// f(x) = x²
// f(x) = 2x² + 4x -7
double a=0, b=0, n, t;
// Abfrage der Daten vom Benutzer
Console.Write("Geben Sie den Anfangintervall an: ");
a = Convert.ToDouble(Console.ReadLine());
Console.Write("Geben Sie den Endintervall an: ");
b = Convert.ToDouble(Console.ReadLine());
Console.Write("Geben Sie die Intervallanzahl an: ");
n = Convert.ToInt32(Console.ReadLine());
t = I(n, a, b);
Console.WriteLine("Das Volumen ist: {0}", Math.PI * t * t);
Console.ReadLine();
}
// Zu berechnende Funktion F(x)
static double F(double x)
{
return x * x;
}
// Berechnung des Integrals.
static double I(double n, double a, double b)
{
int j;
double temp = 0, e, t, h;
h = (b - a) / (2 * n);
for (j = 0; j <= (n - 1); j++)
{
e = a + (2 * j + 1) * h;
t = 5 * F(e - h * Math.Sqrt(3 / 5)) + 8 * F(e) + 5 * F(e + h * Math.Sqrt(3 / 5));
temp = temp + t;
}
return h / 9 * temp;
}
}
}