Answer to Question #257554 in Java | JSP | JSF for NUCHO

Question #257554

Create a program with three methods/functions, The first one takes in n which is the size of an array then creates and populate the array with student names, the second method takes in n which is the size of an array then creates and populate n by 3 array with student marks(The three marks are for test 1 - 3) and finally a method that takes in the two arrays, calculates the final mark of all test and print out the results as indicated below: The first method should return and array of names and the second should return an array all test marks(i.e. 2d array with 3 columns). The third method in addition should also return an array for all the final marks 


Name Test 01 Test 02 Test 03 Final

-------- --------- --------- --------- ---------

Gerry 55 55 55 55 


1
Expert's answer
2021-10-27T16:23:16-0400
public class Main {
 public static String[] f1(int n, String studentName) {
  String[] s = new String[n];
  for (int i = 0; i < n; i++) {
   s[i] = studentName;
  }
  return s;
 }
 public static int[] f2(int n) {
  int[] s = new int[n];
  for (int i = 0; i < n; i++) {
   s[i] = 3;
  }
  return s;
 }
 public static void f3(int[] a, String[] b) {
  for (int i = 0; i < a.length; i++) {
   System.out.println(a[i] + "-" + b[i]);
  }
 }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS