Question: JAVA Add a main() method to the main class CS102 to do the following tasks: 1. Read the organs data from data file named organs.txt

JAVA

Add a main() method to the main class CS102 to do the following tasks:

1. Read the organs data from data file named organs.txt. Each line in this file contains information about the organs (simple organs or donated organs). [1.25 Pt]

A line with an Organ information has the following structure:

Organ: 123, Upper Body, 13.445

A line with a DonatedOrgan information has the following structure:

DonatedOrgan: 983, Lung, 23.4, 44, Khaled

Save all read data in HashSet of type Organ.

2. Print the number of the Organ objects. [1 Pt]

3. Print the number of the Donatedrgan objects. [1 Pt]

4. What is the age of the oldest donor? [1 Pt]

5. What is the age of the youngest donor? [1 Pt]

6. What is the average age of the donors? [1 Pt]

7. Print the name of the oldest donor [0.5 Pt]

8. Print the name of the youngest donor [0.5 Pt]

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 Databases Questions!