CMPS 285 Java Assignment 2


You can complete the first two questions and put them in the same file. The second two questions should be in separate files.

Question 0:


10 points


Write a method called findMean. This method will take in an ArrayList of integers and it will return a double. You will use this method in question 1, so you do not need to test it here.

Please use the following signature: findMean (ArrayList<Integer> list)


Question 1:


10 points


Write a method called findStandardDeviation. This method will take in an ArrayList of integers and will return the standard deviation of the list. Please use the findMean method when necessary. This method will return a double.

Please use the following signature: findStandardDeviation (ArrayList<Integer> list) Please test questions 1 with the follow data set: 75, 80, 85, 95, 100

Question 2:


15 points


Create a class called Person. This person will have two instance variables, getter & setter methods for both variables, and a constructor that assigns values to the instance variables. You should also write a toString method to print out the Person nicely.

Create appropriate instance variables for the name and age of the person

Create an appropriate construction to assign values to the instance variables

Create getter and setter methods for both variables

Write an appropriate toString method that prints both of the instance variables

You do not need to print out the Person yet. You will test it out after you complete the next part.


Question 3:


15 points


You have two options for this question. You may write a class that extends Person or you may write an interface that Person will implement EmployedPerson. You only need to complete one of the following options.

Option 1:


Write the BaseballPlayer class which is a subclass of the Person class. This class will include an appropriate constructor along with a new instance variable which will contain the position that the player has on the team. For example, a player could be the pitcher or outfielder. Override the toString method from the Person class, and print out a message that gives the user some information about the BaseballPlayer. You should print out all three of the properties that the BaseballPlayer contains in the toString method.

Extends the correct class

Appropriate constructor

Appropriate instance variables

Overrides the toString method and provides the required functionality

Make sure that you create a BaseballPlayer in the main method and print it out using the toString method. The method should be implicitly called.

Option 2:


Write an interface called EmployedPerson which will be implemented by the Person class. The interface will contain two methods. One method will be called assignJob and the other will be called printJob. You will need to add one additional instance variable to the Person class to store the job.

*Note* The original Person class will need the be changed in order to complete this option. Just to make partial credit easier please provide an unaltered version of Person (you can rename it to Person2)

Create and implement the interface

Implement the methods in Person class

Change the toString method so it prints all three of the properties of any EmployedPerson

Need a custom answer at your budget?

This assignment has been answered 6 times in private sessions.

© 2021 Codify Tutor. All rights reserved