public class Main {
public static void main(String[] args) {
double X = 0;
double Y = 0;
try { // checking cmd args
if(args.length == 0) throw new IllegalArgumentException();
X = Double.parseDouble(args[0]);
} catch(NumberFormatException e) {
System.err.println("Not a double number! Closing program.");
return;
} catch(IllegalArgumentException e) {
System.err.println("Command line arguments is empty! Closing program.");
return;
}
{ // X processing part
if(X <= -20)
Y = 20;
else if(-20 < X && X <= 30)
Y = Math.sqrt(X);
else if(X > 30)
Y = 30;
}
System.out.println("Y = " + Y); // result part
}
}