301,446 views
36 votes
36 votes
The variable "num" holds an integer user input

Write a conditional statement that does the following:

If num is positive, print "__ is positive"
If num is negative, print "__ is negative"

User Matthew Brent
by
2.6k points

1 Answer

18 votes
18 votes

Answer:

import java.util.*;

class Main {

public static void main(String[] args) {

Scanner inp = new Scanner(System.in);

System.out.print("In");

int num = inp.nextInt();

if(num>0) {

System.out.println(num + "is positive");

}

else if(num < 0) {

System.out.println.(num+ "is negative");

}

}

}

User Liala
by
3.3k points