Java assignment – marks fan task

    Need Solution - Download from here

    Assessment item 2

    Assignment 2

    Value: 20%


    Assessment 2 has 20 marks in total. Marks will be scaled according to the value of the assessment. There are two tasks in assessment 2, Task 1: Processing marks and Task 2: Creating Fan class and testing its properties.

     Task 1

    Value: 12 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 maxmin and range methods will return the maximum mark, the minimum mark and the difference between the maximum and minimum marks respectively.
      • The mean methods will return the mean of the set of marks.
      •  The median method 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 appropriate sort method of the Java API’s Arrays class. 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.
      • The mode method 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.
      • The grades method 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.
      • The gradeDistn method will accept an array of characters, which are the grades assigned for the array of marks, such as returned by the grades method. The gradeDistn method 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 your ProcessMarks class by providing test code either 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: 10
    B: 30
    C: 105
    D: 75
    E: 35

    F: 10



    Task 2

    Value: 8 marks




    Design a class named Fan to represent a rotating fan. The class contains:

    • Three constants named SLOWMEDIUM, and FAST with the values 12, and 3 to denote the fan speed.
    • A private int data field named speed that specifies the speed of the fan (the default is SLOW).
    • A private boolean data field named on that specifies whether the fan is on (the default is false).
    • A private double data field named radius that specifies the radius of the fan (the default is 5).
    • A string data field named color that specifies the color of the fan (the default is blue).
    • The accessor and mutator methods for all four data fields.
    • A no-arg constructor that creates a default fan.
    • A method named toString() that returns a string description for the fan. If the fan is on, the method returns the fan speed, color, and radius in one combined string. If the fan is not on, the method returns the fan color and radius along with the string “fan is off” in one combined string.

    Draw the UML diagram for the class and then implement the class.

    Write a test program that creates two Fan objects. Assign maximum speed, radius 10, color yellow, and turn it on to the first object. Assign medium speed, radius 5, color blue, and turn it off to the second object. Display the objects by invoking their toString method.

    This assignment has been designed to allow students to test and demonstrate their ability to:

      • to interpret design requirements expressed in Unified Modelling Language;use method abstraction in program design (objective 2);
      • to use object-oriented techniques and Java resources to develop small applications consisting of a number of classes (objective 5);
      • be able to apply basic testing and debugging techniques in program development (objective 6);
      • be able to implement basic algorithms in Java (objective 1);

    Marking criteria

    These criteria will be used to evaluate Assignment 2:

    • The tasks are performed as specified and the assignment is submitted as required
    • Appropriate understanding of the subject area is demonstrated, including correct use of appropriate techniques
    • Explanations and discussions are cogent and use clear and correct English expression
    • Referencing is used where appropriate

    Marking guide specific to tasks:




    Material to submit for task 1


    1. You need to submit the java and class files
      2. You also need to submit a doc/pdf file with (a) description of the logic used in the solutions including input and output in your own words (not more than 250 words), (b) copy and paste a snapshot of the program output.

    Material to submit for Task 2


    1. You need to submit the java and class files
      2. You also need to submit a doc/pdf file with (a) copy and paste a snapshot of the program output and (b) UML design


    To complete this assessment you might need to have covered material up to and including the topic Objects and ClassesThinking in Objects, and Arrays in the Text Book and Module.


    By |2017-04-25T16:44:51+00:00April 25th, 2017|Categories: Java assignment help|0 Comments

    Leave A Comment