Modify the C# program to allow it to calculate the average of three numbers instead of the sum. then submit your program to This Drop Box.
C# Program:
using System;
class MainClass {
public static void Main (string[] args) {
Console.WriteLine ("Hello World");
}
}
//The answer code is compiler dependent the user input may not work in some online compilers.
using System.IO;
using System;
class MainClass
{
public static void Main(string[] args)
{
//taking 3 double values for user input values.
double number1,number2,number3;
//taking 3 input from user
Console.Write("Enter the First number: ");
number1 = Convert.ToDouble(Console.ReadLine());
Console.Write("\nEnter the Second number: ");
number2 = Convert.ToDouble(Console.ReadLine());
Console.Write("\nEnter the third number: ");
number3 = Convert.ToDouble(Console.ReadLine());
double result = (number1 + number2 + number3) / 3; //calculating
average of 3 and storing in result variable.
Console.WriteLine("\nThe average of {0}, {1}, {2}is: {3} ",number1,
number2, number3, result);
}
}
Get Answers For Free
Most questions answered within 1 hours.