Expected Run
in1To10(5, false) → true true OK
in1To10(11, false) → false false OK
in1To10(11, true) → true true OK
in1To10(10, false) → true true OK
in1To10(10, true) → true true OK
in1To10(9, false) → true true OK
in1To10(9, true) → false true X
in1To10(1, false) → true true OK
in1To10(1, true) → true true OK
in1To10(0, false) → false false OK
in1To10(0, true) → true true OK
in1To10(-1, false) → false false OK
other tests

how to fix that and improve my approach and design of this challenge. How do i make a graphical venn or ascii diagram to proceed further. Please advise

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

i fixed and passing all tests. Please suggest how to improve my code. Description is too short and i have to read in between lines too to exactly understand to get below

has not tested outsideMode

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

gudii9,
I would also suggest you get out of the habit of using equality with Booleans. We've all grown up with "=" meaning equals but in Java "==" means equals and "=" is the assignment operator. Looking at the results we know that in1To10(9,true) returns false. But suppose, in our code we had something like if(outsideMode = false && n<=10 && 1<=n) return true, then in1To10(9,true) would return true because the "=" assigned the value of false to outsideMode even though our method call was for outsideMode to be true. Sooner or later you will end up doing something like that and not know why it's not working. Even to say if outsideMode == false is superfluous, just say if !outsideMode

Is your question, "Why is the expected result false?" or is it "Why did the above code return true?"
If the former, what leads you to believe that the expected answer would not be "false"?
If the later, what leads you to believe that the above code would not return "true"?
Different misunderstandings may call for different explanations.

public boolean in1To10(int n, boolean outsideMode) {

if(outsideMode==true &&!(n<=10&&n>=1)){

return true;
}

else if(n<=10&&n>=1){

return true;
}

else
return false;

}

my question is above code written by me is not passing all test cases(failing only 1 for whatever reason). Is there is a way i can fix above code to make it pass all the tests? please advise

Given a number n, return true if n is in the range 1..10, inclusive.

Those criteria are invalidated as outsideMode is true. You can concentrate therefore solely on the outsideMode criteria.
By those criteria the result is false since 9 is NOT less than or equal to 1. Neither is it greater than or equal to 10

Given a number n, return true if n is in the range 1..10, inclusive. Unless "outsideMode" is true, in which case return true if the number is less or equal to 1, or greater or equal to 10.

outside mode true means i have to use || as one condition is enough to see n less than 1 or n greater than 10
outside mode false (ie inside mode) means i have to use && as both conditions needed to be tested( greater than 1 and less than 10)

Expected Run in1To10(5, false) → true true OK in1To10(11, false) → false false OK in1To10(11, true) → true true OK in1To10(10, false) → true true OK in1To10(10, true) → true true OK in1To10(9, false) → true true OK in1To10(9, true) → false false OK in1To10(1, false) → true true OK in1To10(1, true) → true true OK in1To10(0, false) → false false OK in1To10(0, true) → true true OK in1To10(-1, false) → false false OK other tests

Observing the first table in http:#a41371926 we see that outsideMode True results are the opposite of the outsideMode False results except when n is 1 or n is 10
But I would still prefer the solution of http:#a41241525, which more directly parallels the description of the problem.
It even places n outside the 1,10 in the outsideMode case, and inside the 1,10 in the !outsideMode case

i was not clear on above comment. what is row and column names here. I am pretty confused on the both tables esp column like 0, 1, 2,....what the mean??

in http:#a41301625,
The cell in the column corresponding to the value of outsideMode,
and the row corresponding to the value of n,
contains the Expected result of in1To10(n,outsideMode)
e.g, for in1To10(1, false)
n=1, outsideMode=false, and the Expected result is true

I'm not sure what seems ambiguous about that representation
But if you want to use a different representation that makes more sense to you,
then I would suggest using that instead.
There's nothing magical about any particular representation,
and anything that helps you to see what's going on can be useful.
Different representations may be helpful for different people or for different aspects of different problems.
But having more ways of looking at problems can make it easier to find one that seems a natural fit, or easier to shift from one to another.
If you think of a program as a way to transform one problem into another, then the goal can be to transform the given problem into a set of problems that have already been solved.

In the second table, the columns represent different tests that might be applied to n,
some of which may turn out to be useful, some of which may not, some of which may need to be combined with other tests to be useful.
But seeing them all at once may help you to find a useful combination, if you find it helpful to think visually.

!=1 and !=10 are missing from that table, but all the information they would provide is given in the ==1 and ==10 columns, (and it was not obvious what the natural order would be to place those columns if they were included)
There was also some judgement involved in deciding that columns like ==1000 might not be worth including in the table.
It may be less clear whether something like <11 or <=9 might be useful, so if you are so inclined you might wish to try adding them to see if they suggest any other solutions.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for freeEdge Out The Competitionfor your dream job with proven skills and certifications.Get started todayStand Outas the employee with proven skills.Start learning today for freeMove Your Career Forwardwith certification training in the latest technologies.Start your trial today