- #1

- 3

- 0

## Homework Statement

Write a user-defined function that calculates grade point average (GPA) on a scale of 0 to 4, where A = 4, B = 3, C = 3, D = 1, and E = 0. For the function name and arguments use av = GPA(g,h). The input argument g is a vector whose elements are letter grades A, B, C, D, or E entered as strings. The input argument h is a vector with the corresponding credit hours. The output argument av is the calculated GPA. Use the function to calculate the GPA for a student with the following record:

Grade B A C E A B D B

Credit Hours 3 4 3 4 3 4 3 2

For this case the input arguments are: g=[‘BACEABDB’] and h=[3 4 3 4 3 4 3 2].

## Homework Equations

None.

## The Attempt at a Solution

I will be honest here, I have not attempted a solution past the point of defining a function with the output av, called the function GPA and with input arguments g and h. This is because I'm not entirely sure how to go from the string that would be inputted into numbers that should be in the GPA function. For example, I understand that B should be equivalent to 3, A should be 4, etc. However, how do I go from the string to numbers? I have tried defining each of the variables, A, B, C, D, and E after the function is defined, however I get errors if I do this.