Advertisement
yovkovbpfps

While Loop Max Number

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