write a java program to display the square and cube of a positive number using ternary operator
Answers
Answered by
3
This Java program allows the user to enter any number. Next, it checks whether the entered value is either positive or negative using Java If Else Statement...
// Java program to find Positive or Negative Number using If Else Statement
package SimpleNumberPrograms;
import java.util.Scanner;
public class PositiveOrNegativeUsingIf {
private static Scanner sc;
public static void main(String[] args) {
int Number;
sc = new Scanner(System.in);
System.out.println("\n Please Enter the any integer Value: ");
Number = sc.nextInt();
if (Number >= 0) {
System.out.println("\n You have entered POSITIVE Number");
}
else {
System.out.println("\n You have entered NEGATIVE Number");
}
}
}
Similar questions