Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Develop a program that looks for the tallest basketball player whose age is less than or equal to the average of all the . There
Develop a program that looks for the tallest basketball player whose age is less than or equal to the average of all the There must be three classes within the program. The first class Height should contain two iinteger instance to represent 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
No matter what the value for inches was supplied to the constructor the toString method should display the height normalized so the inches are less than
The second class Player should contain three instance variables that include the player's name, the player's height, which should be stored as the type Height, and the player's age. The class should be immutable, so it should have no setter methods It should contain the following methods:
A constructor that accepts a player's 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 Project should continuosly prompt the user for the information for each of the players. It should then 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started