Solved

return message not number

Posted on 2002-03-31
2
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

724 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