Advertisement
Spocoman

06. Max Number

Aug 28th, 2024 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 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.         String input = scanner.nextLine();
  7.         int maxNum = -1000000000;
  8.  
  9.         while (!input.equals("Stop")) {
  10.             int n = Integer.parseInt(input);
  11.             if (n > maxNum) {
  12.                 maxNum = n;
  13.             }
  14.             input = scanner.nextLine();
  15.         }
  16.        
  17.         System.out.println(maxNum);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement