Â
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
This assignment has been answered 4 times in private sessions.
© 2024 Codify Tutor. All rights reserved