Wednesday, June 16, 2021

Java program to get a number from the user and print whether it is positive or negative (Java) (180)

package com.company;
import java.util.Scanner;
public class Program17 {
public static void main(String[] args) {
Scanner put= new Scanner(System.in);
System.out.println("please enter a number:");
int num=put.nextInt();
if(num>0)
{
System.out.println("you enter a positive number");
}
else
{
System.out.println("you enter a negative number");
}
}
}

No comments:

Post a Comment