Value: 10 marks For this task you will create a class containing a number of static methods for processing an array of marks, which are scores in a test. Each mark is an integer in the range 0 to 100 inclusive. On the Interact site for this subject, you will be provided with a class Marks, which has a method getMarks that returns an array of marks for you to use in testing.The class ProcessMarks that you create will have the methods specified below. Most will accept an array of marks as an argument; one will accept an array of characters. The return type should be appropriate for the returned value.
The following points should be taken into account in the design of your program:
Test your ProcessMarks class, either by providing test code in a main method within that class or in a separate class. The test code will use an array of marks obtained from the getMarks method of the Marks class provided on the Interact site. Test each one of the methods described above, displaying the results appropriately. The grades should be displayed 30 per line with a space separator between grades. The grade distribution should be displayed in the form: A: 10B: 30C: 105D: 125E: 35
Material to submit
The material to submit for each task is described in the section Assessment Information in this Subject Outline, under the heading Presentation.
Value: 10 marks For this task you will create a Point3D class to represent a point that has coordinates in three dimensions labeled x, y and z. You will then use the class to perform some calculations on an array of these points. The Point3D class will have the following state and functionality:Three fields, x, y and z, of type double, represent the point’s coordinates.A no-arg constructor creates a point at position (0, 0, 0).Another constructor creates a point with specified coordinates.A getter method is provided for each of the fields.An accessor method named distance returns the distance between the current point and another point passed as an argument.The distance method is overloaded to accept the coordinates of the other point.Write a TestPoint3D class that will have a main method, and perhaps other methods as required by good design, to test your Point3D class. It will not have user input because this class will stand as a record of the tests you have applied and you will be able to run it whenever you alter your Point3D class. The test class should contain the following:Test the basic state and functionality of the Point3D class. Each of the constructors and each of the methods should be tested using some different data values. The test code should display values so that they can be checked.Write some code to create an array of at least 10 Point3D objects.Write a method max, which will accept the array of points as an argument, and will calculate and display the maximum distance between the points in the array, and the pair of points for which the maximum occurs.Write a method min, which will accept the array of points as an argument, and will calculate and display the minimum distance between the points in the array, and the pair of points for which the minimum occurs. Material to submit
The material to submit for each task is described in the section Assessment Information in this Subject Outline, under the heading Presentation.
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();
}
}
}