Advertisement
veronikaaa86

06. Max Number

Jun 5th, 2021
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. package whileLoop;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06MaxNumber {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. String input = scanner.nextLine();
  10.  
  11. int maxNum = Integer.MIN_VALUE;
  12. while (!input.equals("Stop")){
  13. int num = Integer.parseInt(input);
  14.  
  15. if (num > maxNum) {
  16. maxNum = num;
  17. }
  18.  
  19. input = scanner.nextLine();
  20. }
  21.  
  22. System.out.println(maxNum);
  23. }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement