Krassi_Daskalova

ForLoop_MaxNumber

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