Solved

return message not number

Posted on 2002-03-31
2
191 Views
Last Modified: 2010-03-31
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
Comment
Question by:LittleRedHat
2 Comments
 
LVL 6

Accepted Solution

by:
kotan earned 300 total points
ID: 6909472
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
 

Author Comment

by:LittleRedHat
ID: 6909491
Many thanks Kotan.  I can't believe how much time I've spent trying to make it more complicated!!! :-)

LRH
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 88
sites similar to codingbat to improve coding hanson skills 3 49
throw exception 21 44
CSV file parsing thru Java 13 28
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question