The sign of a number

Report a typo

Write a method with the name sign that takes an int number and checks whether the number is negative, positive or zero. The method should return -1, +1 or 0 respectively.

Sample Input 1:

11

Sample Output 1:

1

Sample Input 2:

0

Sample Output 2:

0

Sample Input 3:

-3

Sample Output 3:

-1
Write a program in Java 17
import java.util.Scanner;

public class Main {

public static int sign(int number) {
// write your code here
}

/* Do not change code below */
public static void main(String[] args) {
final Scanner scanner = new Scanner(System.in);
final int n = scanner.nextInt();
System.out.println(sign(n));
}
}
___

Create a free account to access the full topic