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.
Declaring methods
The sign of a number
Report a typo
Sample Input 1:
11Sample Output 1:
1Sample Input 2:
0Sample Output 2:
0Sample Input 3:
-3Sample Output 3:
-1Write 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));
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.