-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHow_many_oddEven.txt
More file actions
84 lines (58 loc) · 1.82 KB
/
Copy pathHow_many_oddEven.txt
File metadata and controls
84 lines (58 loc) · 1.82 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<<<<<<< HEAD
import java.util.Scanner;
public class Work1{
public static void main(String[] args){
System.out.println("Enter a list of positive numbers, one per line");
System.out.println("Use a negative number to indicate the end of input");
int num;
int even = 0;
int odd = 0;
int zeros = 0;
Scanner keyboard = new Scanner(System.in);
System.out.println("Please input a number:");
num = keyboard.nextInt();
while(num>= 0){
if (num == 0){
zeros =+ 1;
}
else if (num % 2 == 0){
even += 1;
}
else{
odd += 1;
}
num = keyboard.nextInt();
}
System.out.println("Thank you");
System.out.println("You entered " + even +" even numbers and "+ odd +" odd numbers and " + zeros +" zeros");
}
=======
import java.util.Scanner;
public class Work1{
public static void main(String[] args){
System.out.println("Enter a list of positive numbers, one per line");
System.out.println("Use a negative number to indicate the end of input");
int num;
int even = 0;
int odd = 0;
int zeros = 0;
Scanner keyboard = new Scanner(System.in);
System.out.println("Please input a number:");
num = keyboard.nextInt();
while(num>= 0){
if (num == 0){
zeros =+ 1;
}
else if (num % 2 == 0){
even += 1;
}
else{
odd += 1;
}
num = keyboard.nextInt();
}
System.out.println("Thank you");
System.out.println("You entered " + even +" even numbers and "+ odd +" odd numbers and " + zeros +" zeros");
}
>>>>>>> f51d678b0c3912d8241bd7c8561dcdbea94d2868
}