Question 3 : Write a program in Java to to check whether a number given by the user is negative or positive.
Java Program :
public class number_type
{
public static void main(int a)
{
if (a>0)
System.out.println("The number "+a+" is positive");
if (a<0)
System.out.println("The number "+a+" is negative");
if (a==0)
System.out.println("The number "+a+" is neutral");
}
}
Explanation : There is a simple logic applied here that if a number is greater than 0, it is positive, if it is less than 0, it is negative, and if it is equal to 0, then it is neutral.
Input :
(i) a=10
(ii) a=-10
(iii) a=0
Output :
(i) The number 10 is positive
(ii) The number -10 is negative
(iii) The number 0 is neutral
Java Program :
public class number_type
{
public static void main(int a)
{
if (a>0)
System.out.println("The number "+a+" is positive");
if (a<0)
System.out.println("The number "+a+" is negative");
if (a==0)
System.out.println("The number "+a+" is neutral");
}
}
Explanation : There is a simple logic applied here that if a number is greater than 0, it is positive, if it is less than 0, it is negative, and if it is equal to 0, then it is neutral.
Input :
(i) a=10
(ii) a=-10
(iii) a=0
Output :
(i) The number 10 is positive
(ii) The number -10 is negative
(iii) The number 0 is neutral
Aww :) awesome!
ReplyDeletenice work
ReplyDeleteyoo hoooooooooooooooooo I like it man nice work .but it's not the thing I need .
ReplyDeleteAll are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.
ReplyDeleteSelenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training
This is very good content you share on this blog. it's very informative and provide me future related information.
ReplyDeleteData Science Tutorial
Data Science training in anna nagar
Data science training in jaya nagar
Data science training in pune
Data Science Training in Marathahalli
Data science training in kalyan nagar