Design a class named fan to represent a rotating fan

Assignment Help JAVA Programming
Reference no: EM131482987

Assessment Programming in Java

Task 1

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 max, min 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, 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: 10

B: 30

C: 105

D: 75

E: 35

F: 10

Task 2

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

• Three constants named SLOW, MEDIUM, and FAST with the values 1, 2, 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.

Reference no: EM131482987

Questions Cloud

What is required for a person to be considered unemployed : What is required for a person to be considered unemployed? How is the unemployment rate computed?
The purpose is to become familiar with the behavior : The purpose is to become familiar with the behavior of materials in specific applications. The technical paper will build upon course material.
Total percentage return of stock investment : What is the total percentage return of your stock investment?
Find the growth in globalization and trade liberalization : The classical model relies on competitive markets for labor, products, and capital to keep the economy near full employment and output.
Design a class named fan to represent a rotating fan : create a class containing a number of static methods for processing an array of marks. Design a class named Fan to represent a rotating fan.
Annual sales figure when evaluating project : Required: What is the amount to use as the annual sales figure when evaluating this project?
What suggestions would you give the foundation : In 2006, Warren Buffett, the world's second richest individual, announced that over the next few years he would be giving 85% of his wealth, over $30 billion.
How do humans impact the environment : How do humans impact the environment? Can humans improve their environment? If so How? Explain the Green Revolution?
What is the aftertax cost of debt : The bond currently sells for 92 percent of its face value. The company's tax rate is 40 percent. What is the aftertax cost of debt?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd