Created
January 11, 2019 16:27
-
-
Save penzur/f50e3ce32da3460f0dcffd41cb5d03f0 to your computer and use it in GitHub Desktop.
Ian's Java Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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