Create a console program that will perform the following:
•
Ask the user to enter five (5) grades
•
Compute the average of the grades
•
Round of the average using method of Math class
Example output:
Enter 5 grades separated by new Line.
90
83
87
98
93
The average is 90.2 and round off to 90.
using System;
namespace MathApp
{
class Program
{
static void Main(string[] args)
{
int [] Marks = new int [5];
int Sum = 0;
for (int i = 0; i < 5; ++i)
{
Console.WriteLine($"Enter {i + 1} mark");
Marks[i] = int.Parse(Console.ReadLine());
Sum += Marks[i];
}
Console.WriteLine($"The average is {(decimal)Sum/5} and round off to {Math.Round((decimal)Sum/5)}.");
}
}
}
Comments
Leave a comment