java - Need assistance with importing an array for a programing newbie -


i'm doing assignment uni, have create class file (processmarks.class) calculate max, min, range, mode, median etc. array of 125 integers have been provided our lecturer in class called marks.class, generates array of 125 'marks' between 0 , 100.

so far i'm stuck on multiple fronts assignment, main issue i'm having (which i'm sure basic stuff still can't seem work), i'm trying processmarks.class created import , use marks created in marks.class file , hold results (of marks.class) use needed when user wants calculate min, max, mean etc.

i cant eclipse allow me import class used processmarks.class; keep getting error cant resolved.

  • do need put marks.java or marks.class in specific folder?

  • should run marks.class, , copy, paste , initialise results manually?

  • is there obvious i'm missing or maybe basic java fundamentals i'm not understanding properly?

also i'm not looking work me, need pointed in correct direction.

import java.util.random;  /**  * class provides random array of marks,  * approximately 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 array of nmarks integer marks approximately distributed,      * specified mean (mean) , standard deviation (std),      * , values outside 0..100 removed.      * @return 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();         (int n = 0; n < testmarks.length; n++) {             system.out.print(testmarks[n] + " ");             if (n % 10 == 9)                 system.out.println();         }     } } 

this should started, put inside processmarks.java:

public class processmarks(){     public static void main(string[] args) {         int[] marksarray = marks.getmarks();         //do marksarray      } } 

your teacher has created class static variables, means not need initialize standard new marks(); format. can instead called marks.getmarks(); data. return 125 integers being generated professor's code.

just make sure processmarks.java , marks.java in same folder. suggest using ide work well, common 1 eclipse.

good luck!

[edit] read here learn difference between class files , java files, seem little confused difference is


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -