And the rest is also not correct, I guess you need this:
if (x >= -5) y = x * x;
else y = -x;
System.out.println("y = " + y);
Please help me write a Java program that calculates and prints the piecewise function. on the picture below. I tried to do it myself . Where did I make a mistakes ? Here's what I did :http://s8.postimg.org/bwgulbmit/image.png