Posted: 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
Sponsor Sponsor
Zren
Posted: Wed Apr 16, 2014 8:03 pm Post subject: RE:test score array to letter grade array
return = Return a value from a function.
code:
public static RETURNED_DATA_TYPE toLetterGrades(int[] numericalGrades) {
...
return RETURNED_VALUE;
}
array of ______
code:
DATATYPE[] variableName = new DATATYPE[SIZE];
The datatype for "letter grades" is represented as a "character". Thus: DATATYPE = char
quick question what does this statement above java means
Zren
Posted: 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.
bryce_21
Posted: Thu Apr 17, 2014 12:22 am Post subject: RE:test score array to letter grade array