Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

return message not number

Instead of returning 1,2,3 or 4 I would like this to return "Do this", "Do that", "Do the other" or "Do nothing".  The problem is I don't know/can't work out how.  Help would be appreciated.  

WTA

LRH

/*
    Java Class for applying rules relative to the result
    of the range and average calulation
*/
    public class Rules{
        private int matchRule;
   
    public int getRule (double rangeAvResult){
        matchRule=0;
        if (rangeAvResult <=0.1)
            matchRule=1;
        else if (rangeAvResult >0.1 && rangeAvResult<=0.2)
            matchRule=2;
        else if (rangeAvResult >0.2 && rangeAvResult<=0.3)
            matchRule=3;
        else if (rangeAvResult >0.3)
            matchRule=4;
   
    return matchRule;
    }
}

0
LittleRedHat
Asked:
LittleRedHat
1 Solution
 
kotanCommented:
public class Rules{
   private String matchRule;
   
   public String getRule (double rangeAvResult){
       matchRule = null;
       if (rangeAvResult <=0.1)
           matchRule = "Do this";
       else if (rangeAvResult >0.1 && rangeAvResult<=0.2)
           matchRule = "Do that";
       else if (rangeAvResult >0.2 && rangeAvResult<=0.3)
           matchRule = "Do the other";
       else if (rangeAvResult >0.3)
           matchRule = "Do nothing;
   
   return matchRule;
   }
}
0
 
LittleRedHatAuthor Commented:
Many thanks Kotan.  I can't believe how much time I've spent trying to make it more complicated!!! :-)

LRH
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now