-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
39 lines (31 loc) · 1.17 KB
/
Main.java
File metadata and controls
39 lines (31 loc) · 1.17 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
// Main.java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the size of the array:");
int n = sc.nextInt();
int[] numbers = new int[n];
System.out.println("Enter the numbers:");
for (int i = 0; i < n; i++) {
numbers[i] = sc.nextInt();
}
System.out.println("\nChoose a functionality:");
System.out.println("1. Separate even and odd numbers");
System.out.println("2. Find the two neighboring numbers with the smallest distance");
int choice = sc.nextInt();
// Switch case for function selection
switch (choice) {
case 1:
ArrayFunctions.separateEvenOdd(numbers);
break;
case 2:
int index = ArrayFunctions.findSmallestDistance(numbers);
System.out.println("The index of the first number with the smallest distance is: " + index);
break;
default:
System.out.println("Invalid choice!");
}
sc.close();
}
}