Answer to Question #315617 in C# for Shines

Question #315617

1.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



2. Name the project as ComputeAverageApp and the class as ComputeAverageProgram.



Example output:


Enter 5 grades separated by new Line.


90


83


87


98


93


The average is 90.2 and round off to 90.

1
Expert's answer
2022-03-22T03:58:33-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ComputeAverageApp
{
    class ComputeAverageProgram
    {
        static void Main(string[] args)
        {
            int[] grades = new int[5];
            Console.WriteLine("Please, input 5 grades: ");
            for (int i = 0; i < 5; i++)
            {
                grades[i] = Convert.ToInt32(Console.ReadLine());
            }
            int sum = 0;
            double avg = 0;

            for (int i = 0; i < 5; i++)
            {
                sum += grades[i];
            }
            avg = sum / 5.0;

            Console.WriteLine("The average is {0} and round off to {1}.", avg, Math.Round(avg, 0));

            Console.ReadKey();
        }
    }

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS