3
Answers

GPA Calulator - Converting Input to Value

Max Hemmrich

Max Hemmrich

14y
11.8k
1
I'm trying to code a GPA calculator in Visual Basic 08 for an independent enrichment and have everything set up and am pretty much done, except for the actual GPA calculation part. I have 8 combo boxes, one for each class, where the user can select their grade (A, A-, B+, etc). The part I'm stuck on is the conversion from a letter grade to the corresponding GPA, for example, A = 4.0, A- = 3.7.

I tried using an if statement:

string chineseGrade;
decimal chineseGPA;

if (chineseGrade("A"))
{
chineseGPA = 4.0;
}

but i keep getting the error that "chineseGrade is a variable but is being used as a method" and that "Literal of type double cannot be implicitly converted to type 'decimal'; use an 'M' suffix to create a literal of this type"

What can I do to solve these errors?
Answers (3)
0
Suthish Nair
NA 31.7k 4.6m 14y

If this query got resolved then please Accept the post that helped you as Answer.
So other members can easily find the answers.
0
Suthish Nair
NA 31.7k 4.6m 14y

Sam is right.

change your code too
1. if (chineseGrade=="A")
2. use double chineseGPA or chineseGPA = Convert.ToDecimal(4.0);

0
Sam Hobbs
NA 28.7k 1.3m 14y
chineseGrade is a string variable but you are using it as if it is a method. The compiler is not psychic and neither are we. What is it that you need to do? As best as I understand your question, you are calculating a GPA for Chinese differently than for other people but as far as I know the Chinese are the same as everyone else. So perhaps the answer is that you can just use the same calculation for Chinese people as everyone else.