write a java program to Check whether a short type number taken as input is positive , negative , or Zero by using if else if else statement
Answers
Answered by
13
Answer:
In this program we have specified the value of number during declaration and the program checks whether the specified number is positive or negative. To understand this program you should have the basic knowledge of if-else-if statement in Core Java Programming.
public class Demo
{
public static void main(String[] args)
{
int number=109;
if(number > 0)
{
System.out.println(number+" is a positive number");
}
else if(number < 0)
{
System.out.println(number+" is a negative number");
}
else
{
System.out.println(number+" is neither positive nor negative");
}
}
}
Output:
109 is a positive number
Answered by
2
Explanation:
Program to check POSITIVE, NEGATIVE or ZERO:
-:public class PositiveNegativeExample {
-:public static void main(String[] args) {
-:int number=-13;
-:if(number>0){
-:System. out. println("POSITIVE");
-:}else if(number<0){
-:System. out. println("NEGATIVE");
-:}else{
Similar questions
English,
6 months ago
English,
6 months ago
Chemistry,
1 year ago
Computer Science,
1 year ago
Science,
1 year ago