I'm developing a program and in it, a field from a database is pulled and according to its numerical value, will display one of three things in the GUI: "WARNING", "SEVERE" OR "CRITICAL".
If it is between 0 and 100, it should display "WARNING" If it is between 100 and 200, it should display "SEVERE" If it is over 200, it should display "CRITICAL"
The part of my code that determines this is posted below. I am getting unfavorable results, for any value that is between 100 and 200, "ERROR" is displayed. Is my logic wrong, or is there something deeper going on here?
public class ThreatPanel {
...
final int TEST = 0;
final int TEST2 = 100;
final int TEST3 = 200;
...
}
public void ShowThreats(){
String targetEnd = MainDisplay.getTargetIpHolder();
TargetServerData.setText(targetEnd);
String attackerEnd = MainDisplay.getAttackerIpHolder();
AttackerData.setText(attackerEnd);
int threatLevelEnd = MainDisplay.getThreatLevelHolder();
System.out.println(threatLevelEnd);
if ((threatLevelEnd > TEST ) && (threatLevelEnd < TEST2)){
ThreatLevelData.setText("WARNING");
}
if ((threatLevelEnd > TEST2 ) && (threatLevelEnd < TEST3)){
ThreatLevelData.setText("SEVERE");
}
if (threatLevelEnd > TEST3){
ThreatLevelData.setText("CRITICAL");
}
else{
ThreatLevelData.setText("ERROR");
}
}