Solved

return message not number

Posted on 2002-03-31
2
174 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now