-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q_6.java
47 lines (36 loc) · 1.07 KB
/
Q_6.java
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
// Muhammad Naveed
// (Negative, Positive and Zero Values) Write a program that inputs five numbers and determines
// and prints the number of negative numbers input, the number of positive numbers
// input and the number of zeros input.
import java.util.Scanner;
public class Q_6
{
public static void main(String[] args)
{
int[] numbers = new int[5];
Scanner sc = new Scanner(System.in);
int positive = 0;
int negative = 0;
int zero = 0;
for (int i = 0; i < numbers.length; i++)
{
System.out.print("Enter the number : ");
numbers[i] = sc.nextInt();
}
for (int value : numbers)
{
if ((value > 0)) {
++positive;
}
if ((value < 0)) {
++negative;
}
if ((value == 0)) {
++zero;
}
}
System.out.println("Positive => " + positive);
System.out.println("Negative => " + negative);
System.out.println("Zero => " + zero);
}
}