galinyotsev123

ProgBasicsJavaBook5.1Loops05maxNumber

Jan 15th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E05maxNumber {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. System.out.print("n = ");
  8. int n = scanner.nextInt();
  9.  
  10. System.out.print("Enter the numbers: ");
  11. int max = Integer.MIN_VALUE;
  12.  
  13. for (int i = 0; i < n; i++) {
  14. int num = scanner.nextInt();
  15.  
  16. if (num > max) {
  17. max = num;
  18. }
  19. }
  20. System.out.printf("%d", max);
  21.  
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment