lue: 10 marksFor 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...

1 answer below »
lue: 10 marksFor 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 classMarks, which has a methodgetMarksthat returns an array of marks for you to use in testing.The classProcessMarksthat 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.


  • Themax,minandrangemethods will return the maximum mark, the minimum mark and the difference between the maximum and minimum marks respectively.

  • Themeanmethods will return the meanof the set of marks.

  • Themedianmethod will return the median value of the set of marks. The median value is the middle one when the values are placed in order. To obtain an ordered version of the marks you may use an appropriatesortmethod of the Java API’sArraysclass. Be careful not to destroy the original array of marks. If there is an even number of marks, the middle value is taken as the average of the two values that are nearest to the middle.

  • Themodemethod will return the mode of the set of marks, which is the most commonly occurring mark. To find the mode, use an ordered version of the set of marks, as used for finding the median. If there is more than one value that is most common, any one of the most common values will do for the mode.

  • Thegradesmethod will return an array of characters, which are the grades corresponding to the integer marks in the array of marks. The grades are to be assigned using the following lower boundaries for the corresponding marks: for grade A, the lower boundary is 90; for grade B, it is 75; for grade C, it is 60; for grade D, it is 50; for grade E, it is 45; and F is the grade for all other marks. A best solution for this method would not have the values for the lower boundaries hardcoded but would use an array for these values, which would allow the grade boundaries to be altered.

  • ThegradeDistnmethod will accept an array of characters, which are the grades assigned for the array of marks, such as returned by thegradesmethod. ThegradeDistnmethod will return an array of integer values containing the distribution of grades, which is the number of occurrences of each grade in the assigned grades. The characters used for grades are fixed. The returned array should provide the distribution in order from grade A to grade F.



The following points should be taken into account in the design of your program:


  • None of your code should change the contents of the original array of marks.

  • You should not make any assumption that client code, that would use your methods, should call them in any particular order. That is, you should not assume that a client that calls the range method will have previously called the max and min methods.

Test yourProcessMarksclass, 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 thegetMarksmethod of theMarksclass 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: 10
B: 30
C: 105
D: 75
E: 35F: 10

You need to submit java and class files, a short discussion to explain the logic on how the problem has been solved, and sample output (for detail please see marking guide and presentation below).



Task 2

Value: 10 marksFor this task you will create aPoint3Dclass to represent a point that has coordinates in three dimensions labeledx,yandz. You will then use the class to perform some calculations on an array of these points. You need to draw a UML diagram for the class (Point3D) and then implement the class.
ThePoint3Dclass will have the following state and functionality:


  • Three data fields,x,yandz, of type double, represent the point’s coordinates

  • Additional data field, colour, of type String, represents the point's color

  • A no-arg constructor creates a point at position (0, 0, 0) and "Red" colour.

  • Another constructor creates a point with specified coordinates and colour.

  • A getter method is provided for each of the fields.

  • An accessor method nameddistancereturns the distance between the current point and another point passed as an argument.

  • Thedistancemethod is overloaded to accept the coordinates of the other point.


Write aTestPoint3Dclass that will have a main method, and perhaps other methods as required by good design, to test yourPoint3Dclass. 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 yourPoint3Dclass. For the TestPoint3D class you will need to do the following:





  • Test the basic state and functionality of thePoint3Dclass. 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 10Point3Dobjects.

  • Write a methodmax, 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 methodmin, 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.






You need to submit java and class files, a short discussion to explain the logic on how the problem has been solved, UML diagram, and sample output (for detail please see marking guide and presentation below).

Answered Same DayAug 22, 2020

Answer To: lue: 10 marksFor this task you will create a class containing a number of static methods for...

Sonu answered on Aug 23 2020
144 Votes
Point Cordinates/Documents.docx
To calculate distance between 2 coordinates,
By using square root math metical formulas,
Distance
d=√ (x2−x1)2+(y2−y1)2+(z2−z1)2
To calculate Maximum distance between 2 coordinates in array,
Assume 1st two coordinates points have maximum distance and then compare each coordinates with other coordinates and check distance using already defines method previous distance, and maximum distance will be displayed with their coordinates.
UML Diagram:
Point3Dclass
Attributes
+ colour : String
+ x : double
+ y : double
+ z : double
Operations
+ displayPoints()
+ distance(point Point3DClass)
+ distance(Point3Dclass obj1, Point3Dclass obj2) …
+ getColour() : String
+ getX() : double
+ getY() : double
+ getZ() : double
+ Point3Dclass()
+ Point3Dclass(point3Dclass Point3Dclass)
+ Point3Dclass(x double, y double, z double)
+ Point3Dclass1(x double, y double, z double, col…
+ setColour(colour String)
+ setX(x double)
+ setY(y double)
+ setZ(z double)
TestPoint3Dclass

Attributes
Operations
+ createArray() : Point3DClass[]
+ maximumDistance(Point3Dclass []point3Dclass)
+ minimumDistance(Point3Dclass []point3Dclass)
Point3Dclass
1
TestPoint3D…
1
Point Cordinates/Output.JPG
Point Cordinates/PointCordinates.classdiagram

Point Cordinates/PointCordinates/build.xml

Builds, tests, and runs the project PointCordinates.


Point Cordinates/PointCordinates/build/classes/.netbeans_automatic_build
Point Cordinates/PointCordinates/build/classes/.netbeans_update_resources
Point Cordinates/PointCordinates/build/classes/com/point/cordinate/Point3Dclass.class
package com.point.cordinate;
synchronized class Point3Dclass {
double x;
double y;
double z;
String colour;
public void Point3Dclass();
public void Point3Dclass(Point3Dclass);
public void Point3Dclass(double, double, double);
public void Point3Dclass(double, double, double, String);
public double getX();
public void setX(double);
public double getY();
public void setY(double);
public double getZ();
public void setZ(double);
public String getColour();
public void setColour(String);
public double distance(Point3Dclass);
public double distance(Point3Dclass, Point3Dclass);
public void displayResult();
}
Point Cordinates/PointCordinates/build/classes/com/point/cordinate/TestPoint3Dclass.class
package com.point.cordinate;
public synchronized class TestPoint3Dclass {
public void TestPoint3Dclass();
public void maximumDistance(Point3Dclass[]);
public void minimumDistance(Point3Dclass[]);
public Point3Dclass[] createArray();
public void displayCordinates(Point3Dclass[]);
public static void main(String[]);
}
Point Cordinates/PointCordinates/manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Point Cordinates/PointCordinates/nbproject/build-impl.xml








































































































































































































Must set src.dir
Must set test.src.dir
Must set build.dir
Must set dist.dir
Must set build.classes.dir
Must set dist.javadoc.dir
Must set build.test.classes.dir
Must set build.test.results.dir
Must set build.classes.excludes
Must set dist.jar




































































































Must set javac.includes
































































































































No tests executed.


















...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here