Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package forLoops;
- import java.util.Scanner;
- public class P08NumberSequence {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int maxNum = Integer.MIN_VALUE;
- int minNum = Integer.MAX_VALUE;
- for (int i = 1; i <= n; i++) {
- int currentNum = Integer.parseInt(scanner.nextLine());
- if (currentNum > maxNum) {
- maxNum = currentNum;
- }
- if (currentNum < minNum) {
- minNum = currentNum;
- }
- }
- System.out.printf("Max number: %d%n", maxNum);
- System.out.printf("Min number: %d%n", minNum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement