Computer Science Canada test score array to letter grade array |
Author: | bryce_21 [ Wed Apr 16, 2014 5:52 pm ] |
Post subject: | test score array to letter grade array |
A is >=90 B is 80-89 C is 70-79 D is 60-69 F <60 int [] grades = new int[100]; here the java code char [] scores = double[grade]; for (int i=0; i.length; i++) { if (grades[i] >=90) grades='A'; else if(grades[i] >=80) grades= 'B'; else if (grades[i] >=70) grades= 'C'; else if (grades[i] >=60) grades= 'D'; else (grades[i] <60) grades= 'F'; } return grades; } how to return a character array of letter grades that corresponds to the int array of numerical grades |
Author: | Zren [ Wed Apr 16, 2014 8:03 pm ] | ||||||||||||
Post subject: | RE:test score array to letter grade array | ||||||||||||
return = Return a value from a function.
array of ______
The datatype for "letter grades" is represented as a "character". Thus: DATATYPE = char With that knowledge:
The algorithm for toLetterGrades would be something along the lines of:
You can substitute "for each index of an array" with:
* Insert futile attempt asking to keep all your questions to the same thread. * |
Author: | bryce_21 [ Wed Apr 16, 2014 8:44 pm ] |
Post subject: | RE:test score array to letter grade array |
convertNumericalGradeToLetterGrade(numericalGrade) quick question what does this statement above java means |
Author: | Zren [ Wed Apr 16, 2014 10:00 pm ] |
Post subject: | RE:test score array to letter grade array |
It's the syntax for calling a function. functionName(parameter1, parameter2, ...) Basically, I was hinting that you should make a second function that accepts a parameter representing the numerical grade, and returns a character which represents the letter grade of the given numerical grade. Edit: I purposely used a super long name instead of toLetterGrade (note the singular) so you wouldn't get confused with the first function which accepts an array and returns an array. This second function should accept an integer and return a character. |
Author: | bryce_21 [ Thu Apr 17, 2014 12:22 am ] |
Post subject: | RE:test score array to letter grade array |
thanks for all your help.... |