Computer Science, asked by PrachiG07, 1 day ago

Write an algorithm on:
Q-1 Take a number as input from user and print out whether the number is zero, positive or negative.

Answers

Answered by PranathP
3

Answer:

import java.util.Scanner;

class check

{

public static void main(String[] args)

{

int n;

Scanner sc = new Scanner(System.in);

System.out.println("Enter the number you want to check:");

n = sc.nextInt();

if(n > 0)

{

System.out.println("The number "+n+" is positive.");

}

else if(n < 0)

{

System.out.println("The number "+n+" is negative.");

}

else

{

System.out.println("The given number is 0.");

}

}

}

Refer to the attachment to see the outputs of some examples.

Attachments:
Similar questions