Answer:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a number: ");
int userVal = input.nextInt();
String aString;
if(userVal < 0)
aString = "negative";
else
aString = "non-negative";
System.out.println(aString);
}
}
Explanation:
Ask the user to enter a number and set it to userVal
Check the value of userVal. If it is smaller than 0, set the string as "negative". If it is not, set it as "non-negative"
Print the string