Question: WRITE A PROGRAM ( java program ) to find the tallest basketball player whose age is less than or equal to the average of all

WRITE A PROGRAM (java program) to find the tallest basketball player
whose age is less than or equal to the average of all the players. The program should contain
three classes. The first class Height should contain two integer instance variables for the feet and
inches. The class should be immutable, so it should have no setter methods At a minimum it
should contain the following methods:
A constructor that accepts feet and inches constructs a Height object
A method toInches that returns the height in total inches
A method toString that returns the string representation of the height with a single
quote following the feet and a double quote following the inches
Regardless of what value for inches was supplied to the constructor the toString method should
display the height normalized so the inches are less than 12.
The second class Player should contain three instance variables that include the players name,
the players height, which should be stored as the type Height, and the players age. The class
should be immutable, so it should have no setter methods It should contain the following
methods:
A constructor that accepts a players name, height and age constructs a Player object
Getter methods for each of the instance variables
A method toString that returns the string representation of a player with each field
appropriately labeled
The toString method of the Player class should call the toString method of the Height class.
The third class Project1 should repeatedly prompt the user for the information for each of the
players. It should create a Player object for each player and add the player to an ArrayList. As
the players are read in, the total age of all players should be computed to enable the average to be
calculate once all have been input. Once all player information has been input, the average age of
all players should be output. Then the list of players should be traversed to find the tallest player
whose age is less than or equal to the average age of all players.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!