Input to the program has the form where the first line indicates how many days they will do the operation. For each day, the input starts with the day number, along with the following patient list where each element represents the name of patients and the age. The input ends with the number of available testing kits. The output display, at each midnight, who are going to be tested for the next day. You could use LinkedList which you used in the previous question when new patients come and go. You could use Comparator to compare the age of people. You could use Collections.sort() to sort all people by their age. Once you sort them out, please select a few people depending on the number of available testing kits. So please writhe the pseudo code (or you can write in Java code and submit the Java file with its output). Input : 3 Day1, (Andrew, 19) (Tom, 69) (Elly, 59) (Tin, 55) (Bob, 29), Available Testing Kit of 1 units Day2, (Andy, 44) (Bobby, 88) (Joe, 9) (Trump, 78), Available Testing Kit of 2 units Day3, (Sally, 10), Available Testing Kit of 3 units
Sorting objects in the real world https://docs.oracle.com/javase/8/docs/api/java/util/LinkedList.html
There are 5000 people living in the town. Every day they have new COVID-19 cases.
When people show symptom, they go to the hospital and put themselves in the waiting list for testing. A new person is added at the end of the list. Due to the lack of testing kit, all in the list cannot be tested. Hospital has to sort them and select a few. Since the elderly is very weak to the COVID-19, every midnight the doctors sort the people in the list by their age to decide who is taking the test for the next day depending on the availability of testing kit.
Input to the program has the form where the first line indicates how many days they will do the operation. For each day, the input starts with the day number, along with the following patient list where each element represents the name of patients and the age. The input ends with the number of available testing kits.
The output display, at each midnight, who are going to be tested for the next day.
You could use LinkedList which you used in the previous question when new patients come and go. You could use Comparator to compare the age of people. You could use Collections.sort() to sort all people by their age. Once you sort them out, please select a few people depending on the number of available testing kits.
So please writhe the pseudo code (or you can write in Java code and submit the Java file with its output).
Input :
- 3
- Day1, (Andrew, 19) (Tom, 69) (Elly, 59) (Tin, 55) (Bob, 29), Available Testing Kit of 1 units
- Day2, (Andy, 44) (Bobby, 88) (Joe, 9) (Trump, 78), Available Testing Kit of 2 units
- Day3, (Sally, 10), Available Testing Kit of 3 units
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images