Saturday, May 21, 2022

Sum, Average, Minimum and Maximum Values in C#

 A simple program to solve the sum, average, minimum and maximum values in C# programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg

=================================================


Want to support my channel?

GCash Account

Jake Pomperada

09173084360


Paypal

https://paypal.me/jakerpomperada


Patreon

https://www.patreon.com/jakerpomperada


Thank you very much for your support.





Program Listing

using System;
using System.Linq;

class Max_Min
{
  static void Main(string[] args)
  {
    double[] numbers = { 1.2, 9.3, 1.6, 2.5 };

    DisplayArray(numbers);
    Sum_Average(numbers);
    Max_Value(numbers);
    Min_Value(numbers);

    Console.ReadKey();
  }

  private static void Min_Value(double[] numbers)
  {
    double min = numbers.Min();

    Console.WriteLine("Min is " + min);

  }

  private static void Max_Value(double[] numbers)
  {
    double max = numbers.Max();
    Console.WriteLine("Max is " + max);
  }

  private static void Sum_Average(double[] numbers)
  {
    double sum = numbers.Sum();
    double avg = numbers.Average();
    
    Console.WriteLine("Total is " + sum);
    Console.WriteLine("Average is " + avg);
  }

  private static void DisplayArray(double[] numbers)
  {
    Console.WriteLine("These are the elements in the array:");
    Console.Write("| ");
    foreach(double num in numbers)
      Console.Write(num + " | ");

    Console.WriteLine("\n");
  }
}

No comments:

Post a Comment