0

How to run this code in one file

a. int n = 1; int m = -1; if (n < -m) { System.out.print(n); } else { System.out.print(m); } b. int n = 1; int m = -1; if (-n >= m) { System.out.print(n); } else { System.out.print(m); } c. double x = 0; double y = 1; if (Math.abs(x - y) < 1) { System.out.print(x); } else { System.out.print(y); } d. double x = Math.sqrt(2); double y = 2; if (x * x == y) { System.out.print(x); } else { System.out.print(y); } ====================================== I'm trying to run this code but it doesn't work Please let me know

22nd Jul 2020, 1:34 PM
jjkc
jjkc - avatar
6 Answers
0
You're declaring some variables multiple. The best solution would be to change their names. aNumber and bNumber e.g.
22nd Jul 2020, 1:55 PM
Sandra Meyer
Sandra Meyer - avatar
0
Could you write it for me? i don’t fully understand
22nd Jul 2020, 1:56 PM
jjkc
jjkc - avatar
0
You have all the code, just put it into a file and rename the variables.
22nd Jul 2020, 1:57 PM
Sandra Meyer
Sandra Meyer - avatar
0
what if i don't want to change variables and use n,m and x,y ? can I do it some how?
23rd Jul 2020, 8:43 AM
jjkc
jjkc - avatar