I'm doing an assignment for uni, for which I have to create a class file (ProcessMarks.class) that will calculate the max, min, range, mode, median etc. from an array of 125 integers that have been provided to us by our Lecturer in a class called Marks.class, that generates an array of 125 'marks' between 0 and 100.
So far I'm stuck on multiple fronts for this assignment, however the main issue I'm having currently (which I'm sure is probably basic stuff but I still can't seem to get it to work), is I'm trying to get my ProcessMarks.class that I created to import and use the marks created in the Marks.class file and then to hold the results (of marks.class) to use as needed when a user wants to calculate Min, Max, Mean etc.
I cant get eclipse to allow me import the class to be used by my ProcessMarks.class; I just keep getting an error that it cant be resolved.
Do I need to put the Marks.java or Marks.class in a specific folder?
Should I just run the Marks.class, and then copy, paste and initialise the results manually?
Is there anything obvious that I'm missing or maybe some basic java fundamentals I'm not understanding properly?
Also I'm not looking for anyone to do the work for me, I just need to be pointed in the correct direction.
import java.util.Random;
/**
* A class that provides a random array of marks,
* approximately normally distributed.
* @author Ken Lodge
*/
public class Marks {
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;
}
/**
* Test code
* @param args not used
*/
public static void main(String[] args) {
int[] testMarks = getMarks();
for (int n = 0; n < testMarks.length; n++) {
System.out.print(testMarks[n] + " ");
if (n % 10 == 9)
System.out.println();
}
}
}