Hello. I'm currently working on a C++ assignment where I need to calculate a student's GPA from a text file containing 4 grades and the corresponding credit values for the class.
I know how to write the program to get the correct GPA, but I am having problems figuring out a way to convert the letter values (A, B, C, D) into their numeric values (4, 3, 2, 1). We are not allowed to use a selection statement (if , switch) and have to do this by converting the letters into their ASCII value (by going from a char to an int).
I feel like I should know this, but I've been scratching my brain over how to logically code it.
ch int qpts (quality points)
A -> 65 -> 4
B -> 66 -> 3
C -> 67 -> 2
D -> 68 -> 1
So basically, changing char A to int A converts it into it's ASCII value of 65, and etc for the other letters. The part I haven't been able to figure out is how to change the ASCII value into the quality points value. So I need code to make 65 = 4, 66 = 3, etc. Just pointing me in the right direction would be fine. I have the rest of the program figured out.
Also, don't give me any advanced code for solving this. We're only on chapter 4 and this is an entry-level C++ class, which is why I'm bothered than I'm having trouble with this. Thank you.