Hi everybody, I have a requirement as part of my project where in I am getting a list of integers.The integers are divided into three groups i.e, HIGH(>=80),MEDIUN(<80 && >=20) and LOW(<20).Out of the list I need to pick one integer, but I also need to go through below conditions:
1. If there is just one score of HIGH, we pick this integer as output.
2. If there is more than one score of HIGH, we say an exception has occurred.
3. If there is no score of HIGH, but one score of MEDIUM we pick this integer as output.
4. If there is no score of HIGH, and more than one score of MEDIUM, we say an exception has occurred.
5. If there is no score of HIGH or MEDIUM,but one score of LOW we pick this integer as output.
6. If there is no score of HIGH or MEDIUM,and more than one score of LOW, we say an exception has occurred.
PRORITY: HIGH <-- MEDIUM <-- LOW
I have coded the above requirement as shown below. Guys can you please analyse and share your comments on what improvements can be added to the below code snippet. The code is working as per the requirements.
/*
* Below "scorelist" is the list of scores we are getting as input."hCount/mCount/lCount" are integers used to keep track of which is the only one integer
* found within the three groups."intSelected" gives us the exact score that qualifies the above requirement.
*/
1. If there is just one score of HIGH, we pick this integer as output.
2. If there is more than one score of HIGH, we say an exception has occurred.
3. If there is no score of HIGH, but one score of MEDIUM we pick this integer as output.
4. If there is no score of HIGH, and more than one score of MEDIUM, we say an exception has occurred.
5. If there is no score of HIGH or MEDIUM,but one score of LOW we pick this integer as output.
6. If there is no score of HIGH or MEDIUM,and more than one score of LOW, we say an exception has occurred.
PRORITY: HIGH <-- MEDIUM <-- LOW
I have coded the above requirement as shown below. Guys can you please analyse and share your comments on what improvements can be added to the below code snippet. The code is working as per the requirements.
/*
* Below "scorelist" is the list of scores we are getting as input."hCount/mCount/lCount" are integers used to keep track of which is the only one integer
* found within the three groups."intSelected" gives us the exact score that qualifies the above requirement.
*/