From 763d004565f85b038e72084678d877c6d99ca895 Mon Sep 17 00:00:00 2001 From: Peter Date: Tue, 20 Jun 2017 18:51:24 +0000 Subject: [PATCH] =?UTF-8?q?'PiBerechnen'=20l=C3=B6schen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PiBerechnen | 63 ----------------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 PiBerechnen diff --git a/PiBerechnen b/PiBerechnen deleted file mode 100644 index a0302a6..0000000 --- a/PiBerechnen +++ /dev/null @@ -1,63 +0,0 @@ -using System; - -namespace B_GOP01XX_AG_1 -{ - // Aufgabenschritt 1 - Klassendefinition - class WallisschesProdukt { - - public double calcWP(int n) { - - double halfPI = 1.0; - double step = 1.0; - - for(double i = 1; i < Convert.ToDouble(n); i++, step++) - { - if(i%2 == 0) halfPI *= (step / (step+1)); else halfPI *= ((step+1) / step); - } - - return halfPI * 2.0; - } - } - - - // Aufgabenschritt 2 - Klassendefinition für benötigte Helfer - class Helper - { - public void adjustBuffer() - { - Console.BufferHeight = 2020; - Console.WriteLine("Die \"Pufferhöhe\" der Konsole beträgt nun {0} Zeilen.",Console.BufferHeight); - } - - - static int tableWidth = 77; - public void PrintLine() - { - Console.WriteLine(new string('-', tableWidth)); - } - - } - - - // Aufgabenschritt 3 - Hauptprogramm - class Program { - - static void Main(string[] args){ - - WallisschesProdukt wp = new WallisschesProdukt(); - - Helper testNow = new Helper(); - testNow.adjustBuffer(); - - Console.WriteLine(String.Format("{0, 0}{1,-5}{2, 0}{3, 0}","Faktor:","","","Walissches Produkt:")); - - for (int i = 1; i <= 1000; i++) { - - testNow.PrintLine(); - Console.WriteLine(String.Format("|{0, 4} {1, -5}| {2, 5:F14} | {3, -8:F17} |{4, -5}|", " n =" , i , wp.calcWP(i), Math.Abs((wp.calcWP(i) - Math.PI)), "Abweichung in %")); - } - - testNow.PrintLine(); - } - } -} \ No newline at end of file