Write a program to calculate the average of all scores entered between 0 and 100
ID: 3537366 • Letter: W
Question
Write a program to calculate the average of all scores entered between 0 and 100. Use a sentinel-controlled loop variable to terminate the loop. After values are entered and the average calculated, test the average to determine whether an A, B, C, D, or F should be recorded. The scoring rubric is as follows:
A%u201490-100; B%u201480-89; C%u201470-79; D%u201460-69; F < 60. C# is the language
Explanation / Answer
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace chap6que3 { class Program { static void Main(string[] args) { int[] marks; int minput = 1, counter = 0, total = 0; float aveg = 0.0f; String Gradeletter = "C"; marks = new int[100]; Console.WriteLine("Enter Student Grade"); while (minput > 0) { minput = Convert.ToInt32(Console.ReadLine()); if (minput >= 0) { marks[counter++] = minput; total += minput; Console.WriteLine("Enter student grade or any negative value to calculate average"); } } aveg = (float)total / (float)counter; Console.WriteLine("Average Grade %: " + aveg.ToString()); if (aveg < 60) { Gradeletter = "F"; } else if (aveg >= 60 && aveg < 70) { Gradeletter = "D"; } else if (aveg >= 70 && aveg < 80) { Gradeletter = "C"; } else if (aveg >= 80 && aveg < 90) { Gradeletter = "B"; } else if (aveg >= 90) { Gradeletter = "A"; } Console.WriteLine("Letter grade average is: " + Gradeletter); Console.ReadKey(); } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.