Topics

Multiple Objects

Description

Write a program that will input the names, ages and weights of three siblings and display the lightest followed by the youngest of the siblings.

Do the above assignment without using an array of objects.

Implementation

Create a project asSibling.

In the above project, create a class Sibling not containing the main method.
In the above project, create a class TestSibling containing the main method.

class Sibling

Create a class Sibling. In the class, provide private instance variables for name, age and weight. Provide a constructor with parameters for initializing name, age and weight. Also provide accessor methods getName, getAge and getWeight for getting name, age and weight respectively.

class TestSibling

Create a class TestSibling containing the main method. In the main method, input the name, age and weight of each sibling and create a corresponding Sibling object containing the data.

After all Sibling objects are created, the main method will display the data for the lightest sibling followed by the youngest sibling. The data will include the sibling name, age and weight of the sibling. Use the object accessor methods for getting object data.

Note

For doing this assignment, you need to provide only accessor (getter) methods. You don't need to provide modifier (setter) methods.

Testing:

Input

For testing, use the following input data

Jack 21 130
Judy 24 118
John 26 145

Note that in the above data Jack is 21 years old and weighs 130 lbs.

Output

The program output will appear as below:

The Lightest Sibling: Judy 24 118
The Youngest Sibling: Jack 21 130
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.