I am making a program to calculate someone's GPA based user input. For one of the methods I am writing, I ask the user to enter a letter grade. I then convert the letter to the corresponding GPA. How do I save this GPA to a variable? Would I save it as a variable when I call the method in the program or in the method itself?
public static double GetGradePoint(string LetterGrade)
{
Console.WriteLine("Enter your letter grade for each class");
string letter = Console.ReadLine();
if (letter == "A")
{
return 4;
}
if (letter == "A-")
{
return 3.7;
}
if (letter == "B+")
{
return 3.3;
}
if (letter == "B")
{
return 3;
}
if (letter == "B-")
{
return 2.7;
}
if (letter == "C+")
{
return 2.3;
}
if (letter == "C")
{
return 2;
}
if (letter == "C-")
{
return 1.7;
}
if (letter == "D+")
{
return 1.3;
}
if (letter == "D")
{
return 1;
}
if (letter == "F")
{
return 0;
}
}