-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPositiveNegative.java
More file actions
49 lines (32 loc) · 1.07 KB
/
PositiveNegative.java
File metadata and controls
49 lines (32 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.Scanner;
public class PositiveNegative{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter a number: ");
int number = input.nextInt();
if(number > 0 && number % 2 == 0){
System.out.print("positive even");
}
else if(number < 0 && number % 2 == 0 ){
System.out.print("negative even");
}
else if(number % 2 == 1 && number > 1){
System.out.print("positive odd");
}
else{
System.out.print("negative odd");
}
}
}
/*
Checking the user input if it is a positive and negative number
prompt the user to enter a number
create a variable that reads the users input
check if"user input is greater than zero and check if the user input is divisible by two remainder zero"
print"positive even"
else if "user input is less than zero and it is divisible by 2 remainder zero"
print"negative even"
check if "the user input is greater than one and it is divisibe by 2 remainder one"
print"positive odd"
else print"negative odd"
*/