Write a program that computes the average of five exam scores. Declare and perfo
ID: 3658923 • Letter: W
Question
Write a program that computes the average of five exam scores. Declare and perform a compile-time initialization with five values. Use a constant to define the number of scores. Print all scores and the average value formatted with no digits to the right of the decimal.Explanation / Answer
using System; public class average { public static void Main(string[] args) { double input = 0, average = 0; int numberOfTerms = 1; Console.WriteLine("To end this program, enter a negative number and press any key."); while (input >= 0) { Console.Write("Enter a number in your sequence: "); input = Double.Parse(Console.ReadLine()); if (input > 0) { average = input / numberOfTerms; } numberOfTerms = numberOfTerms + 1; Console.WriteLine("The average so far is {0}.", average); } Console.ReadKey(true); } } You can compile c# using the command line version C:>csc average.cs
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.