How do I pass three arrays from on method to another?
Posted
by
user2966716
on Stack Overflow
See other posts from Stack Overflow
or by user2966716
Published on 2013-11-07T21:46:13Z
Indexed on
2013/11/07
21:53 UTC
Read the original article
Hit count: 170
I have a method studentSummary, that scans the input and creates three arrays examMark,courseworkMark and courseworkWeight. I need these arrays passing over to a different method, so I can use them to calculate moduleResult.
heres my code:
public static int[] studentSummary(int[] courseworkWeight2, int [] examMark2 , int [] courseworkMark2){
int examMark[] = { 0, 0, 0, 0, 0, 0 };
int courseworkMark[] = { 0, 0, 0, 0, 0, 0 };
Scanner resultInput = new Scanner(System.in);
int courseworkWeight[] = { 0, 0, 0, 0, 0, 0 };
for (int k = 1; k < 7; k++) {
System.out.print("Please enter exam marks for module " + k + ":");
examMark[k - 1] = resultInput.nextInt();
System.out.print("Please enter Coursework marks for module " + k
+ ":");
courseworkMark[k - 1] = resultInput.nextInt();
System.out.print("Please enter Coursework weighting for module "
+ k + ":");
courseworkWeight[k - 1] = resultInput.nextInt();
}
Calculator method:
public static int[] markCalculator() {
int[] courseworkWeight = new int [6];
int[] courseworkMark = new int [6];
int[] examMark = new int [6];
for (int i = 0; i < 6; i++) {
computedModuleMark = ((courseworkMark[i] * courseworkWeight[i]) + (examMark[i] * (100 - courseworkWeight[i]))) / 100;
if ((computedModuleMark) < 35) {
if (examMark[i]<35){
}
}
moduleMark[i] = computedModuleMark;
}
computeResult(moduleMark);
StudentChart.draw(moduleMark);
StudentChart.printSummary(moduleMark);
return moduleMark;
}
© Stack Overflow or respective owner