Hi community, i'm JAVA learner and i don't know how to find max and min and sorting array without changing the original array and printing the results. Can anyone help me to fix my java code to find max, min and sorting please ?
Here is my java:
import java.util.Arrays;
import java.util.Random;
import java.util.*;
public class ProcessMarks {
private static final int NMARKS = 125;
private static final double mean = 65.0;
private static final double std = 15.0;
/**
* Returns an array of NMARKS integer marks approximately normally distributed,
* with specified mean (mean) and standard deviation (std),
* and with values outside 0..100 removed.
* @return the array of marks.
*/
public static int[] getMarks() {
Random rand = new Random(1001L);
int mark;
int[] theMarks = new int[NMARKS];
int n = 0;
while (n < NMARKS) {
mark = (int) Math.round(std*rand.nextGaussian() + mean);
if (mark >= 0 && mark <= 100)
theMarks[n++] = mark;
}
return theMarks;
}
public static int max(int[] getMarks) {
int maximum = getMarks[0];
for (int i=0; i<getMarks.length; i++) {
if (getMarks[i] > maximum) {
maximum = getMarks;
}
}
return maximum;
}
/**
* Test code
* @param args not used
*/
public static void main(String[] args) {
System.out.println(" *Maximum Marks is = " + maximum);
int[] testMarks = getMarks();
for (int n = 0; n < testMarks.length; n++) {
System.out.print(testMarks[n] + " ");
if (n % 10 == 9)
System.out.println();
}
}
}