JAVA - Figuring out the difference -
I have the problem below, although I am unable to pass it all the tests, regardless of what approach I take. Does anyone tell me where I am wrong?
Math to Problems Be sure to use the BAS () and IF statements, using a loop / function / etc.
//////////////////////////// Problem statement //////// /////////////////////// Three entries, ABC, are given if one or one of the b is "closed" // // (maximum of 1 Different from), while the other is "distant", which is // // different than that of 2 / or more. Note: Math.abs (num) // // evaluates the full value of a number. // // 1, 2, 10 - & gt; True // // 1, 2, 3 - & gt; False // // 4, 1, 3 - & gt; truth // /////////////////////////////////////////////// //////////////////////////// My Account: if ((Math.abs (ab) & lt; = 1 || Math.abs (A + B) & lt; = 1) & amp; (Math.abs (ac) & gt; = 2 | Math.abs (a + c)> = 2)) {if (Math.abs (ac)> = 2 || Math.abs (a + c)> 2 =) Println ("true"); } And {System.out.println ("wrong"); }} And if (Math.Abus (AC) gt2 = Math.Abs (A) + B)> = 2) {System.out.println ("true"); } And {System.out.println ("wrong"); }} And {System.out.println ("wrong"); }
seems highly complex, maybe you go for something more simple Want:
Boolean abIsClose = Math.abs (ab) & lt; = 1; Boolean ACISCLOS = Math Abs (AC) & lt; = 1; Boolean BCISclose = Math Box (B-C) & lt; = 1; Boolean results = abIsClose & amp; Amp; ! ACIsClose & amp; Amp; ! BcIsClose; Result = results || (AbIsClose & amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp ;; bcIsClose; result = result || (! AbIsClose & amp;; ACI Close & amp; BCISclos) ; Abe always gives a positive number, thus you do not need to confirm a value between -1 and 1, you only need to confirm & lt; = 1 .
Comments
Post a Comment