You could just fill out the entire dictionary from 0 to 100 with the grade for that score. I upvoted the other answers as they are all valid. You only need to update the dictionary in the constructor.Įdit 2: I have seen that someone downvoted every answer. It is easier to extend when you want to change a grade. How to Calculate GPA If you’re homeschooling high school, you will likely need to figure your student’s overall grade point average (GPA) for his high school transcript. If statements or cases would work great too, but I prefer this method of development. 70-79 C 60-69 D 59 and below F Using the examples above, 75 would earn a C letter grade. That being said, there are probably better ways to handle this.Įdit: This assumes that you don't have B- or other grades that happen when a grade of 88 is passed into the method. public class GradesĬhar value = GradeValues Now that you have this dictionary set up, you can take the grade into your method, divide by 10, take the floor and find the entry associated with that value. Any help is appreciated.Ĭode: public static void Main(string args)Ĭonsole.WriteLine("How many scores would you like to enter? ") ĪRRAYLENGTH = Convert.ToInt32(Console.ReadLine()) Ĭonsole.Write("Enter your test score " + (i + 1) + ": ") Ĭonsole.WriteLine("\nThis is your average = " + (sum / test.Length)) Ĭonsole.WriteLine("\nYour grade is: ") //Not sure how this would workĬonsole.Write("\nPress the key to exit.") I am trying to output the total percentage grade based on the inputted grades, and also output the actual letter grade, but I am having trouble figuring out what I would code to convert to letter grades. I have written a program that allows a user to enter how many grades they would like to input into an array, and then lets them enter the grades for the number of indexes they chose.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |