Skip to content

Instantly share code, notes, and snippets.

@penzur
Created January 11, 2019 16:27
Show Gist options
  • Save penzur/f50e3ce32da3460f0dcffd41cb5d03f0 to your computer and use it in GitHub Desktop.
Save penzur/f50e3ce32da3460f0dcffd41cb5d03f0 to your computer and use it in GitHub Desktop.
Ian's Java Sample
import java.util.*;
public class a {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter number: ");
int count = sc.nextInt();
int min = 0;
int max = 0;
for (int i=0; i < count; i++) {
System.out.print("Enter a number: ");
int n = sc.nextInt();
if (i == 0) {
max = n;
min = n;
} else {
if (n < min) {
min = n;
}
if (n > max) {
max = n;
}
}
}
System.out.println("Min: " + min);
System.out.println("Max: " + max);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment