Solved

return message not number

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 98
Core java. Create the class with method that do logic for all elements of collection. 1 68
firstChar challenge 13 107
eclipse formatting 6 71
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

911 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

16 Experts available now in Live!

Get 1:1 Help Now