-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
32 lines (27 loc) · 918 Bytes
/
Copy pathSolution.java
File metadata and controls
32 lines (27 loc) · 918 Bytes
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
package basic.loops;
import java.util.Scanner;
public class Solution {
public static void main(String args[]) {
int positive = 0, negative = 0, zeros = 0;
System.out.println("Press 1 to continue & 0 to stop");
Scanner sc = new Scanner(System.in);
int input = sc.nextInt();
while (input == 1) {
System.out.println("Enter your number : ");
int number = sc.nextInt();
if (number > 0) {
positive++;
} else if (number < 0) {
negative++;
} else {
zeros++;
}
System.out.println("Press 1 to continue & 0 to stop");
input = sc.nextInt();
}
System.out.println("Positives : " + positive);
System.out.println("Negatives : " + negative);
System.out.println("Zeros : " + zeros);
sc.close();
}
}