Computer Science, asked by Saloni5174, 9 months ago

Write a java programming using function to see a number is positive or negative​

Answers

Answered by Zisha7
0

Answer:

Java Program to Check if a Given Integer is Positive or Negative

  1. public class Postive_Negative.
  2. int n;
  3. Scanner s = new Scanner(System.
  4. System. out. print("Enter the number you want to check:");
  5. n = s. nextInt();
  6. if(n > 0)
  7. System. out. println("The given number "+n+" is Positive");
  8. else if(n < 0)
Answered by mn121
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