static void Main() { Random rand = new Random(); AdvCalc calc = new AdvCalc(); for (int i = 0; i < 1000; i++) { calc.Add(rand.NextDouble()); } Console.WriteLine($"Average: {calc.Average()}"); //Console.WriteLine("Average: {0}",calc.Average()); }
public static void Main(string[] args) { AdvCalc calc = new AdvCalc(); Random rnd = new Random(); for (int i = 0; i < 1000; i++) { calc.Add(rnd.NextDouble()); } Console.WriteLine("Sum: {0}", calc.GetSum()); Console.WriteLine("Average: {0}", calc.GetAverage()); }
public static void Main(string[] args) { AdvCalc calc = new AdvCalc(); Random r = new Random(); for(int i = 0; i < 1000; i++) { calc.Add(r.NextDouble()); } Console.WriteLine("Sum: {0}", calc.GetSum()); Console.WriteLine("Average: {0}", calc.GetAverage()); }
static void Main(string [] args) { AdvCalc calc = new AdvCalc(); Random r = new Random(); for (int i = 0; i < 1000; i++) { calc.Add(r.NextDouble()); } Console.WriteLine($"sum: {calc.GetSum():F2}"); //neue Variante direkt in den Platzhalter den Code Console.WriteLine("avg: {0:F2}", calc.GetAverage()); //ältere Variante :F2 floating point number 2 NK }