using System.Collections.Concurrent;
public static class Memory
public static ConcurrentDictionary<string, long> GradeRank;
public static void Initialize()
Memory.GradeRank = new ConcurrentDictionary<string, long>();
Memory.GradeRank.TryAdd("A", 80);
Memory.GradeRank.TryAdd("B", 70);
Memory.GradeRank.TryAdd("C", 60);
Memory.GradeRank.TryAdd("D", 50);
Memory.GradeRank.TryAdd("E", 40);
public static void Main()
Console.WriteLine("Input operation command:");
string input = Console.ReadLine();
Console.WriteLine("A Grade: >={0}\nB Grade: >={1}\nC Grade: >={2}\nD Grade: >={3}\nFail: <{3}", GetScore("A"), GetScore("B"), GetScore("C"), GetScore("D"));
else if (input.Trim() == "q")
string[] args = input.Split(',');
double[] doubleArgs = Array.ConvertAll(args, s => double.Parse(s));
double avg = ComputeAverage(doubleArgs);
Console.WriteLine("Your average score is: " + avg + '\n');
string[] grades = GetLetterGrades(doubleArgs);
Console.WriteLine("Letter grade for each score entered: [" + string.Join(",", grades) + "]" +'\n');
string[] sortedoutput = BubbleSort(doubleArgs, "s");
Console.WriteLine("Score sorted in descending order: [" + string.Join(",", sortedoutput) + "]" + '\n');
public static double GetScore(String grade)
if (Memory.GradeRank.ContainsKey(grade))
score = Memory.GradeRank[grade];
public static double ComputeAverage(double[] scoreArray)
for (i = 0; i < scoreArray.Length; i++)
average = (double)sum / scoreArray.Length;
public static string[] GetLetterGrades(double[] scoreArray)
string[] letterGrades = new string[scoreArray.Length];
for (i = 0; i < scoreArray.Length; i++)
if (scoreArray[i] >= 0 && scoreArray[i] <50)
else if (scoreArray[i] >= 50 && scoreArray[i] <60)
else if (scoreArray[i] >= 60 && scoreArray[i] <70)
else if (scoreArray[i] >= 70 && scoreArray[i] <60)
else if (scoreArray[i] >= 80)
public static string[] BubbleSort(double[] scoreArray, string method)
for (int p = 0; p <= scoreArray.Length - 2; p++)
for (int i = 0; i <= scoreArray.Length - 2; i++)
if (scoreArray[i] > scoreArray[i + 1])
temp = scoreArray[i + 1];
scoreArray[i + 1] = scoreArray[i];
return output = Array.ConvertAll(scoreArray, s => s.ToString());