galinyotsev123

ProgBasics06For-Loop-P04maxNumber

Jan 5th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P04maxNumber {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int n = Integer.parseInt(scanner.nextLine());
  7. int max = Integer.MIN_VALUE;
  8.  
  9. for(int i=0; i < n; i++){
  10. int currentNum = Integer.parseInt(scanner.nextLine());
  11.  
  12. if (currentNum > max){
  13. max = currentNum;
  14. }
  15. }
  16. System.out.println(max);
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment