write a program to input a number to find whether it is positive or negative
Anonymous:
which language?
Answers
Answered by
2
hey mate
here is your answer
//a program in Java to find
//whether a number is
//positive or negative
import.Java.util.*;
class positive_negative
{
public static void main (string args [])
{
Scanner sc=new Scanner (System.in);
system.out.println ("enter a number");
int n=sc.nextInt();
if(n>0)
system.out.println ("positive number");
else
system.out.println ("negative number");
}
}
assumption:all the inputs are of int data type
here is your answer
//a program in Java to find
//whether a number is
//positive or negative
import.Java.util.*;
class positive_negative
{
public static void main (string args [])
{
Scanner sc=new Scanner (System.in);
system.out.println ("enter a number");
int n=sc.nextInt();
if(n>0)
system.out.println ("positive number");
else
system.out.println ("negative number");
}
}
assumption:all the inputs are of int data type
Similar questions
English,
7 months ago
English,
7 months ago
Chemistry,
7 months ago
Environmental Sciences,
1 year ago
Physics,
1 year ago