How do I write a method that takes an array of Strings as a parameter and works out a total numerical score. As an example, {"A", "B"} would give a score of 3+2 = 5. The method returns
this score as an int. if my program below is as follow:
public class ModuleAnalyser
{
private int score;
public int turnAnswerToScore(String myGrade)
{
if(myGrade == "A") {
score = 3;
}
else if(myGrade == "B") {
score = 2;
}
else if(myGrade == "C") {
score = 1;
}
else if(myGrade == "D") {
score = 0;
}
return score;
}
}
Start Free Trial