Expected Run
in3050(30, 31) → true true OK
in3050(30, 41) → false false OK
in3050(40, 50) → true true OK
in3050(40, 51) → false true X
in3050(39, 50) → false false OK
in3050(50, 39) → false false OK
in3050(40, 39) → true true OK
in3050(49, 48) → true true OK
in3050(50, 40) → true true OK
in3050(50, 51) → false true X
in3050(35, 36) → true true OK
in3050(35, 45) → false false OK
Correct for more than half the tests

Look at how your code is handling the not OK cases, and see if you can figure out why it is getting the wrong answer.
You may also want to think about how you are doing the range 30..40 inclusive and

Think more carefully about what in the range 30..40 inclusive means, and what Math.abs(a-30)>=10 means

0

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Think more carefully about what in the range 30..40 inclusive means, and what Math.abs(a-40)<=10 means
Think about what happens when a is 29, 30, 31, 39, 40, 41

Another hint: How would you test for in the range -10..10?

>> why it is not spontaneous yet with java language unlike english language?
I think that's because you use the method Math.abs()
I wonder why you use it for this challenge?

Let's do it in English:
Checking if an int x is in the range 30...40 is just as simple as
1) checking that x is 30 or more
but ALSO
2) checking that x is no more than 40, thus 40 or less

In java
1) x >= 30
AND
2) x <= 40

Hence, checking if an int x is in the range 30...40 is just as simple as:

if ( x>=30 && x<=40) {
}

You have to check if both a and b are in the range 30..40, so that just doubling what you already had above:
if ( (a>=30 && a<=40) && (b>=30 && b<=40) ) {
}

And you have to check it for another range: 40...50, so that's replacing 30 by 40 and 40 by 50:
if ( (a>=40 && a<=50) && (b>=40 && b<=50) ) {
}

So the eventual result is:

public boolean in3050(int a, int b) { if ( (a>=30 && a<=40) && (b>=30 && b<=40) ) { // a and b in the range 30...40? return true; // Yes! } if ( (a>=40 && a<=50) && (b>=40 && b<=50) ) { // a and b in the range 40...50? return true; // Yes! } return false; // no succes (otherwhise, we shouldn't have come till here)}

Above solution works great.. in my mind i was struck with one direction of Math.abs for this challenge. How to keep mind working thinking on all different directions and possibilities.

public class Test8 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub boolean b=in3050(30, 51); System.out.println("b is-->"+b); } public static boolean in3050(int a, int b) { if ( a>=30 && a<=40 && b>=30 && b<=40 ) { // a and b in the range 30...40? return true; // Yes! } if ( a>=40 && a<=50 && b>=40 && b<=50 ) { // a and b in the range 40...50? return true; // Yes! } return false; // no succes (otherwhise, we shouldn't have come till here) }}

>> Above solution works great..
Then why didn't you give it any points?

0

Featured Post

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.
So …

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio. You will also find the …

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 …