This is a java program to calculate a number which is Positive number or Negative number.
This is basic if else formula .
You can go to jaca tutorial by click here: -->đđ
Source Code:
- public class PositiveNegetiveDemo {
- public static void main(String[] args) {
- try (Scanner input = new Scanner(System.in)) {
- int num;
- System.out.print("Enter the number: ");
- num = input.nextInt();
- if(num > 0) {
- System.out.println("positive.");
- }
- else if(num < 0) {
- System.out.println("Negative.");
- }
- else {
- System.out.println("Equals to Zero.");
- }
- }
- }
- }
Output:
Enter the number: 5
positive.
Enter the number: -9
Negetive.
Enter the number: 0Equals to Zero.
0 comments:
Post a Comment