-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHW6P3.java
More file actions
38 lines (37 loc) · 1.18 KB
/
HW6P3.java
File metadata and controls
38 lines (37 loc) · 1.18 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
import java.util.Scanner;
public class HW6P3 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n1, n2, i, place = 0;
boolean found = false;
int[] arr;
System.out.print("Enter n1: ");
n1 = input.nextInt();
System.out.print("Enter n2: ");
n2 = input.nextInt();
arr = new int[n2];
System.out.print("Enter " + n2 + " values: ");
for(i = 0; i < arr.length; i++) {
arr[i] = input.nextInt();
}
for(i = 0; i < arr.length; i++) {
if(arr[i] == n1) {
found = true;
place = i;
}
}
if (found && place == arr.length -1) {
System.out.println("No values after " + n1);
} else if(found == false) {
System.out.println(n1 + " does not occur");
} else {
for(i = place + 1; i < arr.length; i++) {
if(arr[i] % 2 == 0) {
System.out.println(arr[i] + " is even");
} else {
System.out.println(arr[i] + " is odd");
}
}
}
}
}