-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinimumNumberChallenge.java
More file actions
40 lines (33 loc) · 1.03 KB
/
MinimumNumberChallenge.java
File metadata and controls
40 lines (33 loc) · 1.03 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
import java.util.Scanner;
public class MinimumNumberChallenge {
public static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Enter count");
int count = scan.nextInt();
scan.nextLine();
int [] numbers = readIntegers(count);
int min = findMin(numbers);
System.out.println("min = " + min);
}
public static int[] readIntegers(int capacity){
int[] array = new int[capacity];
System.out.println(" Please enter " + capacity + " Integer values");
for(int i=0;i<array.length;i++) {
int number= scan.nextInt();
scan.nextLine();
array[i] = number;
}
return array;
}
public static int findMin(int[] array) {
int min=Integer.MAX_VALUE;
//3,4,5
for(int i=0;i<array.length;i++){
int value = array[i];
if(value < min){
min=value;
}
}
return min;
}
}