Write a java programming using function to see a number is positive or negative
Answers
Answered by
0
Answer:
Java Program to Check if a Given Integer is Positive or Negative
- public class Postive_Negative.
- int n;
- Scanner s = new Scanner(System.
- System. out. print("Enter the number you want to check:");
- n = s. nextInt();
- if(n > 0)
- System. out. println("The given number "+n+" is Positive");
- else if(n < 0)
Answered by
0
public class integer
{
public static void main(String[] args)
{
Scanner in = new Scanner(System. in);
int n;
System.out.print("Enter a number: ");
n = in. nextInt();
integer ob = new integer();
ob. check(n);
}
public void check(int x)
{
if(x<0)
System.out.println( x+" is negative");
else if(x>0)
System.out.println( x+" is positive");
else
System.out.println( x+" is zero");
}
}
Hope it helps you...
Please mark it as brainliest...
☺️☺️☺️
Similar questions