Advertisement
Bob103

C#_methods

Sep 19th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. class Program
  2.     {
  3.         static void Main()
  4.         {
  5.             Console.Write("Enter a: ");
  6.             double a = double.Parse(Console.ReadLine());
  7.             Console.Write("Enter b: ");
  8.             double b = double.Parse(Console.ReadLine());
  9.             Console.Write("Enter the accuracy of the calculations e: ");
  10.             double e = double.Parse(Console.ReadLine());
  11.             Console.Write("Enter step: ");
  12.             double h = double.Parse(Console.ReadLine());
  13.             for (double x = a; x <= b; x+=h)
  14.             {
  15.                 int count = 1;
  16.                 double temp = 1;
  17.                 double pov = (6 * x * x) / (2 * count * (2 * count - 1));
  18.                 while (Math.Abs(pov) >= e)
  19.                 {
  20.                     ++count;
  21.                     temp += pov;
  22.                     pov *= (-1) * (6 * x * x) / (2 * count * (2 * count - 1));
  23.                 }
  24.                 Console.WriteLine("x: {0} \t f(x): {1} \t last f<{2}>: {3}", x, temp,count, pov);
  25.             }
  26.         }
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement