In: Computer Science
Write a C# program using repl.it that asks the user for three integers and prints the average value as a double. Example calculation (3 + 6 + 7) / 3 = 5.33333333333333 Given the data above, the output should be similar to: The average for the values entered is: 5.33333333333333 As always comments in your code are expected (what why how etc… ) Submit your repl.it link to the assignment dropbox text submission area.
using System;
class MainClass {
static void Main(String[] args) {
Console.WriteLine("Enter 3 values: ");
//reading 3 values from user
int val1 = Convert.ToInt32(Console.ReadLine());
int val2 = Convert.ToInt32(Console.ReadLine());
int val3 = Convert.ToInt32(Console.ReadLine());
// adding and dividing it with 3
double average=(val1+val2+val3)/3.0;
//printing average
Console.WriteLine("Average : "+average);
}
}
Note : If you like my answer please rate and help me it is very Imp for me